I am getting a maddening error trying to load an html page(with angular/javascript,etc) from a content editor inside a sharepoint 2013 aspx.page. I have several sites where I do the exact same thing(using the same template) and it works without issue.

This site page doesn't want to work using the exact same code. I am at my wits end as to why this is happening and throwing an error. Basically I get a blank page at the end because it keeps throwing errors about sp.js, then SP.Publishing and the SP.Pub being undefined and then it doesn't do anything after that, except give me a blank page.

I already am using

<script type="text/javascript"> $(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(function () { }, "sp.js"); }); </script>

I have also put the Microsoft.Ajax script on the page that defined Type but to no avail, still get the same error.

on the index html page, so this should be waiting for it to load, but it isn't.

I checked and double checked my code between the pages that are working without issue and this one and the markup is exactly the same, and the code is the same as well.

Does anyone know why this would be happening??

UPDATE: The crazy thing about this is, it works in edit mode when I apply the link but not once I go to the page directly...this is very irritating

2 Answers 2


I never work with this document-ready construct. I always use

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', yourInitFunctionToCall);

at the top of the script described e. g. in this post

That the edit page behaves differnt could be a hint to the order of script references. Especially with Angular the order is important. If the above executeFunc does not help you may post how you've lined up the references for the other script-files / how your script header looks like.

  • Thanks for the feedback...I attempted to use this one, but to no avail...same issue. I don't think the order of the scripts is an issue because I use the exact same order in several other pages and it loads without issue. There is something really weird going on here that I cannot figure out... Why does the SP object not have a Publishing property that it is trying to reference??
    – MattE
    Commented Jun 8, 2018 at 13:00
  • Hmh, so if you build a page similar to this crap page it works too? Is this rotten page the current homepage of the site? Assuming that your init function is not empty like in your 1st post what happens if your init function is empty? What happens if you just execute a simple javascript alert at start and erase the Angular part? Sorry for the question spam, but I'm just thinking about some effects we've experienced...
    – Celophysis
    Commented Jun 11, 2018 at 7:50
  • It appears they made a change to the publishing settings at the admin level that I cannot do anything about. It tries to load SP.Publishing.Resource which is undefined and then crashes and does nothing. Anyway around this?
    – MattE
    Commented Jun 16, 2018 at 4:21

OK, I finally figured out how to get this to work after at least 15 hours spent looking up and trying literally everything I could find. I still am not exactly sure why it works, but it works.

Basically I create a content editor but instead of linking it to an HTML page in the site assets folder, I rename the HTML page to an ASPX page and it works, and that is really it.

All that time and effort and simply renaming the HTML page to an ASPX page is all that it took to get it to work.

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.