I have read that you need to use Script Editor WP instead of CEWP when embedding JavaScript into a page rather than using a Content Editor WP. In testing, it seems that CEWP works fine with HTML/JS/CSS.

My method is to reference a .HTML file through the CEWP. This html file has references to external .js and .css files. All seem to load fine. I've even tested directly putting script blocks into the html file (e.g. an alert in a script block within the head of the html file) and that also works just fine.

Are the articles that suggest using CEWP over SEWP out of date? Is my farm just special?

Just as a note, I'm not trying to avoid SEWP for fun. Being able to update an HTML file on the server rather than do what must be done to update a SEWP is much more convenient. SEWP update procedure = [Go to page]->[Click edit]->[Click edit snippet]->[Paste new html]->[Apply]->[Check in if necessary]. These procedures are filled with slow pauses and room for error. JS does not 'update' after inserting code, so fishy things can go wrong. JS also seems to lose scope in some cases when in page edit mode. It's also a maintenance nightmare to have a separation of code like this -- a js and css file exist, but the html is just inserted into a page.. somewhere!

2 Answers 2


If you are referencing an external file using CEWP then it works. But if you try to add a script block directly inside the webpart content, then it will not work.

SharePoint removes all the script from Content Editor web part. Use Script Editor web part instead.

Another difference is, Content Editor web part can be exported and script editor web part doesn't allow you by default. Script Editor web part having default export mode of ‘Do Not Allow’.

  • 2
    So if I stick to just referencing an external .html I'll never see a difference in behavior from 2010 to 2013? That's good to hear!
    – ferr
    Dec 22, 2014 at 16:22
  • 1
    Yes. That is correct. Dec 22, 2014 at 16:22
  • Thanks for the info, every article I read seems to ignore this and it shouldn't be ignored.. will mark as answer asap.
    – ferr
    Dec 22, 2014 at 16:23
  • Do you have any authoritative sources for this information? I'd like to pass this on if I can.
    – ferr
    Dec 22, 2014 at 16:24
  • You can try this yourself by adding the webpart. I will look around for some source. Dec 22, 2014 at 16:25

I personally use a CEWP for most of my scripts. Like Amal said, as long as you reference a file I don't see what the problem would be.

Being able to put your file in your Site Assets library and being able to have a central location for it is very beneficial for reuse. I can't imagine having to update every SEWP on a site for a .js file that I use on 10 different pages.

Also, like you said, it is more of a pain to go in and make a single change to the script if it is in a SEWP.

That being said, if it is a script that I am only going to use on a specific page to hide something or move something via css, I would use a script editor. So I wouldn't say that they are worthless.

Your Answer

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

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