ScriptBlock="alert('script block loaded');" Sequence="100">
Script on Demand
At the end of the file that is going to load dynamically you need to add this line of code:
This function is used to register the file for the Script on Demand that you want to load later.
SP.SOD.registerSod accepts two arguments, the key for the file and its SharePoint path. This function registers the file in the SharePoint memory so that it will be loaded dynamically.
- Do not always load all your files in SharePoint using CustomAction. It will slow down SharePoint performance.
- You can load files when they are needed by SOD at event, button click, page load etc.
- Register the file using the function SP.SOD.registerSod("key", ?jspath");
- Use executeFunc to load the file when needed. This method executes a callback function once the loading is done by SharePoint: SP.SOD.executeFunc(?key???, null, callback);