Do u know the difference between jquery $(document).ready and $(window).load ???


I thought, that there is no difference between these two. That both work and do stuff,
when the page has loaded. WRONG!!!
$(document).ready work when the DOM is ready.
That means that can be executed even when the pictures have NOT been loaded, cause the DOM is ready (the structure of the page and its elements)
But, when you need to do something, when EVERYTHING has loaded,
comes the $(window).load.
I found it out, when i needed to pass a javascript variable at the start of the page, and do something with that. I made it with $(document).ready and $(window).load

I found also this relative article. Check it out!


Well-Known Member
Staff member
'window' is the top level object that contains the 'document object', which contains the page elements.

Not understanding such basics is one of the problems with the way that so many people think that "jquery" is all that is ever needed.


ok, sorry for posting this info to the forum.
There is nothing to do with understanding. Is just a clarification for these two.
I wont do it again!
Everyone in here, know everything!
No sharing info again!


Well-Known Member
Staff member
My comment wasn't a dig at you, it was simply a general gripe about the 'popular' idea that no one ever needs to learn the basics of a programming or script language, and they can just jump in with an additional layer of complexity of a "framework" and hope "it just works". I saw another example yesterday at a different forum where the person was using "Bootstrap CSS" but did not know enough basic CSS to figure out why some radio buttons were truncating the caption text if it was too long for the container. Very few seem to grasp the idea that knowing the basics means not waiting several hours for somebody else to spoon feed an answer.

It's a bit like them hoping to solve simultaneous equations before learning the "times tables".


New Member
The ready() method makes a function available after loading the document. Whatever code you write inside the $( document ).ready() method will run once the page DOM is ready to execute JavaScript code.

The code which gets included inside $( window ).on( "load", function() { ... }) runs only once the entire page is ready (not only DOM).
Note: The load() method is deprecated in jQuery version 1.8. It was completely removed it in version 3.0. To see if it's working, add the jQuery version for CDN before 3.0.