Can we use ExecuteOrDelayUntilScriptLoaded
in application pages. If yes, do I need to add sp.js
to the project to make it work?
2 Answers
Since SP.SOD.executeFunc supports on demand scripts, but SP.SOD.executeOrDelayUntilScriptLoaded does not, I would recommend to use SP.SOD.executeFunc
with CSOM
:
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {
var clientContext = SP.ClientContext.get_current();
console.log(clientContext.get_url());
});
-
1
ExecuteOrDelayUntilScriptLoaded is a method used to delay a function call unless a particular script is loaded. Yes, you can use it in application page. If you are using CSOM you need to add a reference to sp.js file.
You can also use SP.SOD.executeFunc if you are using on demand scripts.
A very good article on this is here