1

I'm trying to add jquery to my Seattle masterpage. I followed these directions which say to add the following (modified for my locations) line to the Seattle.html file.

<!--SPM:<SharePoint:ScriptLink language="javascript" name="'~sitecollection/_catalogs/masterpage/custom/js/jquery-1.8.3.min.js" runat="server" Localizable="false" />-->

I added that line right after the other ScriptLinks that were already there. I then load the page back up and I get the "Something went wrong error" when I try and load any page (all the admin ones) that uses it.

Is that the wrong location to add that line?

How can I add jquery to my Seattle masterpage?

1

Easier than modifiyng the MasterPage:

Use the Chrome Extension SharePoint Editor once

https://chrome.google.com/webstore/detail/sp-editor/ecblfcmjnbbgaojblcpmjoamegpbodhd?hl=en

to load jQuery with a UserCustomAction ScriptLink

That will load jQuery early on on every page in the SiteCollection

  • That looks like it is for SP online? I should have specified that we have 2013 on prem. – Rothrock Apr 26 '17 at 15:35
  • UserCustomActions have been around since SP2010, never tried it but that extension should work on all environments, if not check John Lui's blog on UserCustomActions – Danny '365CSI' Engelman Apr 26 '17 at 16:31
  • I couldn't get the extension to do anything, but John Liu's blog worked! – Rothrock Apr 26 '17 at 20:46
0

An alternate method is to add the <script> tag directly in <head> section in master page as the following:

  • Upload your js file to Asset Library or Style Library in SharePoint site collection.

  • Open SharePoint Designer > Go to Master Page > Right click on your custom master page HTML file and Check it out.

  • Right click -> Edit in advanced mode.
  • In < head > section add your reference of your js file like <script type="text/javascript" src="../../Style Library/JS/jquery7.min.js">

Note: To get the correct URL > write Src=" > then the Pick URL button should be shown, navigate to your js file in Style Library.

  • Save -> Right click Check-in -> Publish As Major version ->

Enter image description here

  • This is will open your master page gallery -> right click and select publish.

Enter image description here

Alternatively, you can use delegate control as mentioned at Adding jQuery to Every Page in SharePoint with Delegate Controls

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.