views:

1665

answers:

4

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?

+5  A: 

Hi, 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" %>
Ric Tokyo
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
yep, changing whats there is ill advised, adding to it, is encouraged.
Ric Tokyo
+3  A: 

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/.

Alex Angas
+1  A: 

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.

Waldek Mastykarz - MOSS MVP
+1  A: 

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

Muhimbi