Can anyone tell me how I can use:

ExecuteOrDelayUntilScriptLoaded(myFunction, "sp.js");

in my Client Web Part pages (App Parts)?

In my standard pages it loads fine but when I try use this function in an app part page I keep getting an undefined error:

enter image description here

What resource/script do I need to load on the page to get this function to work?


I had this same issue and this worked for me


Make sure you add a reference to init.js script

 <script type="text/javascript" src="/_layouts/15/init.js"></script>

I have not tried the following, but it should work after loading init.js

SP.SOD.ExecuteOrDelayUntilScriptLoaded(myFunction, "sp.js");

I would have though that it would be in either the SP.js or the SP.Core.js file (although I can't confirm for definite). But have you tried:

SP.SOD.ExecuteOrDelayUntilScriptLoaded(myFunction, "sp.js");

  • Yes, I tried that immediately after posting the question. Exact same error. If I inspect the SP object, it exists but SP.SOD is undefined. Really frustrating as it's hard to find documentation around this in the context of App Parts.
    – Ray Hogan
    Apr 19 '16 at 11:45

Your Answer

