What is the difference between $(document).ready() and $(window).load() in jQuery?

1 Answers
Answered by suresh

What is the difference between $(document).ready() and $(window).load() in jQuery?

Difference between $(document).ready() and $(window).load() in jQuery

$(document).ready() is a jQuery function that is called when the DOM is fully loaded and ready to be manipulated. It is typically used to run jQuery code that needs to be executed as soon as the DOM is ready.

$(window).load() is a jQuery function that is called when all assets on the page, including images and scripts, are fully loaded. It is typically used to run code that relies on the size or dimensions of assets to be loaded before executing.

Therefore, the main difference is that $(document).ready() is focused on the DOM being ready, while $(window).load() is focused on all assets being loaded.

Answer for Question: What is the difference between $(document).ready() and $(window).load() in jQuery?