Does the JavaScript below allow a webpage load quicker opposed to the a standard function or $(window).load(function(){ OR $(document).ready() if not is there a way to allow the page to load then run JavaScript ?
setTimeout(function(){
// JavaScript OR jQuery to execute
}, 5000);
Description
$(document).ready()Specify a function to execute when theDOMis fully loaded.The function ensures that all html elements (
DOM) is loaded. So it is not a good idea to usesetTimeoutbecause you cant know if the browser has built theDOMin this time.You can put your JavaScriptat the end of your document to make sure the browser has built the
DOMbut thats not the way you should do that in case of using jQuery.More Information
DOMmeans Document Object ModelThe following functions are the same (overloads) in jQuery.
– jQuery Documentation – .ready()
– Wikipedia – Document Object Model