Difference between page load and document.ready?

`document.ready` and "page load" refer to two different events in the lifecycle of a web page.

1. Page Load: This event occurs when all the resources on a web page, including images, scripts, stylesheets, etc., have finished downloading and rendering. It signifies that the entire HTML document, along with its associated resources, has been loaded and is ready for interaction. This event is triggered by the browser's `load` event.

2. `document.ready`: This event, often associated with jQuery, occurs when the DOM (Document Object Model) hierarchy is fully constructed, but before the browser has finished rendering the page. It means that the DOM elements are ready to be manipulated via JavaScript or jQuery, but some external resources like images may still be loading. It is triggered by jQuery's `$(document).ready()` function or its shorthand `$(function() { ... })`.

In summary, "page load" refers to the complete loading of all resources on a page, while `document.ready` refers to the point at which the DOM is ready for manipulation but before the page's resources have finished loading.

Comments

Popular posts from this blog

How to maintain state in asp.net core

What is react and vite

How to find 2nd highest salary simple way in sql server