Contents
How to add JavaScript after whole page load?
You are right, MANY things happen on page after $ (document).ready (). 2013 does provide a few options. 1) Script on Demand: (load a js file then execute my code.) Cant find a source on _spBodyOnLoadFunctionNames but I am using it in a few places.
Then, in the calendar hook he attaches his own function to the: SP.UI.ApplicationPages.CalendarStateHandler.prototype.onItemsSucceed function. It works ok both for SP 2010 and 2013. The idea of on demand script loading make really sense. SharePoint 2010 loads really a lot of JavaScripts – this takes time!
How does on demand script loading work in SharePoint?
It works ok both for SP 2010 and 2013. The idea of on demand script loading make really sense. SharePoint 2010 loads really a lot of JavaScripts – this takes time! So the idea is: first load the HTML and let it render by the browser so that the user is able to read the requested information as fast as possible.
ExecuteOrDelayUntilScriptLoaded:sp.core.js. SP.SOD.executeFunc: sp.js. Sys.WebForms.PageRequestManager.PageLoaded – ExecuteOrDelayUntilBodyLoaded function is always executed the first (but at this stage we can not access to SP methods).
When to execute JavaScript after a page load?
The second approach is right to execute JavaScript code after the page has finished loading – but you don’t actually execute JavaScript code there, you inserted plain HTML. The first thing works, but loads the JavaScript immediately and clears the page (so your tag will be there – but nothing else).
When do I need to load a script file?
You can load the script file when a user performs an action which needs the script instead loading it always. Here is a code I am using and which is working for me.