I was looking at potential ways to include jQuery and Paul Grenier's Accordeon Quick launch (https://www.nothingbutsharepoint.com/sites/eusp/Pages/jquery-for-everyone-accordion-left-nav-with-cookies-speed-test.aspx) into a site master page and came across this blog post:


Christophe commented to the post:

And of course this is not THE solution, let alone the best way, to add custom JavaScript or jQuery to SharePoint. This is just a solution. For example your way is not recommended:

  • when you just use jQuery on one specific page
  • when you only need jQuery after the page has loaded
  • when you are not even sure if the user will use your jQuery customization on the page ( tooltips for example)
  • etc.

I added 2 script references to the master page (for jQuery and Paul's script), and was wondering what others thought of this approach.

I removed all my jQuery script references from my CEWPs, many of which use jQuery, and they still run fine (because jQuery is now on every page by way of the master page).

I don't use jQuery scripts on every page in my site but I use it on many pages. Is there another approach that I should consider?

2 Answers 2


As I am quoted in the question, and also to follow up on Abe's reply: there are several other ways to include jQuery and JavaScript in a Master Page.

The post in the original question shows an old school method, which is to add a script tag to the head section of the page. The author doesn't explain why he thinks it is the best way, and I simply believe that he is wrong.

Some script tags could for example be added at the bottom of the body section. This would be an option if the plugin only needs to be activated after the page has loaded.

I did some research, and here are other approaches I found (some might not apply to MOSS):


Delegate controls, which seem to be more for developers:




Now, I still don't know which of these is to recommend, and it will certainly depend on the context. I am also interested in insight from master designers!

  • Hey Christophe! I don't know about being a master designer, but we use jQuery quite heavily and we use the delegate controls option adding it to the additional page head delegate control at the Farm level. It works for us and we do not see a performance hit as of yet. Commented Apr 22, 2011 at 7:22

If you are going to be using jQuery on more than just a few pages this should be fine. Adding it to the individual pages would be a pain and difficult to maintain.

Also, I would still use this method even if you only need jQuery after the page has loaded. If you need it use it...

I also disagree with the exclude when you are "not even sure if the user will use your jQuery". If the functionality will help a significant number of users then keep it. If it's not helping anyone then it shouldn't be there.

  • 1
    Abe, I am the author of the above comment. My point is not to exclude jQuery, but to include it in a more efficient way. The post mentioned in the question just adds jQuery in the head section, and doesn't consider other practices like lazy loading.
    – Christophe
    Commented Apr 22, 2011 at 2:22
  • I see your point. Have you seen real world improvement from lazy loading? While it is more efficient, I have yet to see these types of performance tweaks generate any real improvement. It's entirely possible that this is due to the fact that I have not worked on any insanely high traffic web sites though... Commented Apr 22, 2011 at 2:45
  • An obvious example is SharePoint 2010 (ribbon, calendar). It's not just about high traffic, it's also about priorities when the browser renders the page content. Let me post a separate reply to show other options.
    – Christophe
    Commented Apr 22, 2011 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.