I am trying to use jquery in CEWP. In my html script, I am providing jquery reference which is available in SiteAssets library. I am using jquery library for some fancy slider.

When I save html script the web part editor it includes reference of jquery as attribute of HTML tag. First time it works fine with no issue. Whenever I edit the html script of web part, SharePoint includes the reference of jquery again and it keeps on increasing with every edit of html script. Because of which effect of jquery gets wrong.

I am not able to figure the issue. Is there some limitation of using jquery with CEWP? Is there any work around of this?

  • The issue is not specific to jQuery.
    – Christophe
    Dec 20, 2011 at 17:15

2 Answers 2


My prefered method of attack is to create the jquery script as a JS file and store it in the site assets library. Then using a content editor web part on the desired page where the script should be, I put the URL of the JS file in the link to content box.

Then in SharePoint Designer, I can make updates to the JS file as needed and refresh the SharePoint page to see the effect of my changes.

Edit: You could also apply it to your master page and it will be available on every page.

  • 1
    I use the same technique here and it's nice. The content link doesn't mangle the JavaScript and editing it in SPD through the Site Assets library (or any document library) makes for instant updates during development/debugging/tweaking.
    – Bil Simser
    Dec 9, 2011 at 18:55

You could load the Jquery libary to your _layouts folder. That way it will get cached on the web front end instead of residing in the content database.

Once the library is loaded, you can add your script files. I like to save them in a script folder in the style library, but however you do it is fine. Then reference your script like PirateEric said.

I'm not sure why it's stacking loads. Perhaps using the methods mentioned will keep it from happening.

Your Answer

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

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