Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

We are about to undertake a rather large customization of SharePoint and I wanted to get some feedback prior to jumping in with both feet. One of the issues we are kicking the tires on is do we deploy the jQuery javascript library to the 12 hive directly (making it available in _layouts for each site etc.) or do we wrap it up in a feature and activate that feature for each site? I have also seen two projects on CodePlex that wrap it up in features and that could be a third option I guess.

Thoughts?

share|improve this question
add comment

5 Answers 5

up vote 11 down vote accepted

options and commentary on www.sharepointblogs.com

follow the link above or google it.

Summary is that modifying the 12 hive directly is easy but unsupported (i.e. Microsoft reserves the right to destroy your environment at will)

recommended option on above link is:

Use the AdditionalPageHead Delegate Control (my favorite!)

By providing the contents for the AdditionalPageHead Delegate Control that is used by all the out-of-the-box master pages, you can make sure the the jQuery library is loaded by all the SharePoint pages. The AdditionalPageHead Delegate Control allows multiple controls to provide contents, so it’s a great extensibility scenario. To accomplish this you need to build a web user control (ASCX file), that contains the script tag to load the jQuery library:

<%@ Control Language="VB" ClassName="jQueryControl" %>
share|improve this answer
1  
Modifying Microsoft-provided files in the 12 hive is unsupported, but adding new files (ideally with a WSP) is absolutely supported and essential to SharePoint development... –  dahlbyk Aug 27 '09 at 16:18
    
yep, changing whats there is ill advised, adding to it, is encouraged. –  Ric Tokyo Sep 4 '09 at 3:43
    
The link is not working in this article –  Andi Apr 2 '13 at 19:52
add comment

You could also use the Google AJAX Libraries API. By adding some script to your SharePoint master page (for example), any version of jQuery you prefer can be downloaded from Google without any need to deploy the .js file.

There are also numerous potential speed improvements:

  • Google's jQuery .js file may already be cached in the users browser (thanks to other sites using this facility)
  • browsers usually only allow a certain number of connections to the same server, so this allows another connection to open in parallel
  • the file is downloaded from the users nearest geographical location (I think)

This is an increasingly popular solution that I've heard nothing but good things about. Check it out at: http://code.google.com/apis/ajaxlibs/.

share|improve this answer
    
You should still program a local backup in case you don't have a outside connection. –  trgraglia Feb 19 at 14:10
add comment

I'd say it depends on your scenario. If you want to make the jQuery library available for a single site only, using Features is the way to go. If you want to make it globally available however, deploying it to 12 is the way to go.

share|improve this answer
add comment

We deploy it to the 12 hive as part of our free SharePoint Infuser tool, which you may want to consider to deploy JavaScript (inc JQuery) to multiple pages in one go without using any messy changes to masterpages, core.js etc.

Internally it uses the delegate control approach proposed by Ric above, it is just a more generic solution and can be used for all kind of purposes.

For details see http://www.muhimbi.com/blog/2009/07/massage-sharepoint-into-submission.html. For a very powerful example of what this makes possible, see http://www.muhimbi.com/blog/2009/07/automatically-add-search-as-you-type-to.html

share|improve this answer
add comment

I couldn't get the code from www.sharepointblogs.com to work. I had better luck using this link http://blogs.msdn.com/b/kaevans/archive/2011/04/06/adding-jquery-to-every-page-in-sharepoint-with-delegate-controls.aspx

share|improve this answer
    
perhaps you could include the reason you couldn't get it to work and show the differences between the two implementations. –  Nick DeVore Apr 29 '11 at 20:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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