Adel Adel - 4 months ago 18
jQuery Question

jQuery (window).load() did not acces second time

I'm working on WordPress theme that has a preloading screen, this screen gets hide after entire page complete loading, and my code works perfectly for the past few months, but now the preloading screen did not get hide because the code did not access into (window).load() or window.onload = function ().

(function ($) {
console.log("Start");
window.onload = function () {
console.log("Done");
};
})(jQuery);


The result is "Start" even The page is complete download and the browser shows me entire page.

Info : I'm using WordPress 4.5 multi-website.

Thanks

Answer

You have a function which Immediately executes termed as IIFE and have a window.onload handler in it.

There is no way window.onload handler will not invoke if it is inside IIFE