Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
The issue is not specific to jQuery. –  Christophe Dec 20 '11 at 17:15
add comment

2 Answers

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.

share|improve this answer
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 '11 at 18:55
add comment

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.

share|improve this answer
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.