Load jQuery Once Per Page in SharePoint

If you have several scripts on a SharePoint page that all need to reference the jQuery library file, then you may end up in a situation where the library is loaded multiple times. This will cause a conflict and various execution errors. The following script will load jQuery once per page in SharePoint.

This can be avoided by adding a Content Editor Web Part to the page and including the following script in the source (or as a reference to a script file). Once the page is loaded, the jQuery library file will be available to other scripts loaded on the page and you avoid having conflicts. The other scripts will no longer need to load the jQuery library so remove external file references in those scripts.

In this example, my copy of jQuery is stored in a Document Library labeled “code” which would need to be changed to align with your particular folder structure. I am also loading both the standard jQuery library and the SPServices jQuery library.

Leave a Comment