Reputation: 3665
i just wondering is there any performance issue or anything thing wrong if that a $(window).load(), is set within a $(document).ready()
due to some element only can be determined after window is loaded such as dynamic size of an inline div or image, with height:auto, while 80% of the function should start working on document.ready.
Upvotes: 1
Views: 102
Reputation: 34107
Nopes, no issues.
[Quote] This works fine and is an acceptable practice. After all, as you describe, there may be cases where the logic in the $(window).load() handler depends on work taking place after the DOM is ready. If the window is in fact already loaded by the time you set up $(window).load(), the handler will just fire immediately. [UnQuote]
"$(document).ready() runs as soon as the DOM has loaded, but $(window).load() will not run until the DOM has loaded AND all dom resources have loaded (like images and CSS files and stuff). That means that $(document).ready() will run before you set the value." read more here
window load inside a document ready?
Hope this helps for your understanding you can always read more in Jquery documentations.
cheers!
Upvotes: 1
Reputation: 236092
No. No issue with that at all.
You're just assigning an event handler to an event, which of course, will fire some time after DOMContentLoaded
.
Upvotes: 0