Page 1 of 1

Load javascript after page is completely loaded

Posted: 19 Sep 2016
by peisenschmidt
In sharepoint I need to load javascript after page is completely rendered.

So this is what I did:



function LazyLoad(){
console.log("JS loaded after page rendering");
}
_spBodyOnLoadFunctionNames.push("LazyLoad");



I guess, _spBodyOnLoadFunctionNames can not access "LazyLoad" function because it is not defined globally. How to load the function "LazyLoad" after everything is initialized?

Re: Load javascript after page is completely loaded

Posted: 19 Sep 2016
by peisenschmidt
Got my solution:

ExecuteOrDelayUntilScriptLoaded(LazyLoad, "sp.ribbon.js");

Re: Load javascript after page is completely loaded

Posted: 19 Sep 2016
by peisenschmidt
he latest script that get's loaded is "sp.ui.spellcheck.js". (Actually it's "O365ShellG2Plus.js", but that does not load.)

So best answer:

ExecuteOrDelayUntilScriptLoaded(LazyLoad, "sp.ui.spellcheck.js");