DEV Community

mixbo
mixbo

Posted on

4

What difference window.ready with document.ready

Alt Text

JQuery are basically used in project, aways defined events callback like $(document).on('ready', function(){}) when document reday. but there has one things Interest me, what is different window.onload with document.ready ?

window.onload

This event must wait for all elements on the page to loaded then execute this function after rendering

document.ready

This event be executed as soon as the dom is loaded ignore other Asset(images,videos) if ready

Also confuse? let's talk a simple example

Simple example

We create new chrome tab with url request page, this page havs many images.

When the page DOM are loaded but images, window.ready won't be trigger until images loaded browser will trigger this callback

As long as page DOM is loaded even if image is not loaded browser will trigger document.ready

One words

window.ready : trigger when page all DOM and Asset(images, videos) are rendered ready

document.ready trigger when page loaded render process rendered even if Asset(images, videos) not ready

Hope it can help you :)

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (2)

Collapse
 
victormagarlamov profile image
Victor Magarlamov

good drawing )

Collapse
 
ihavecoke profile image
mixbo

keep learning every day :)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay