Tech N Toast®

Explaining the Window Load event

window load

It fires when our HTML document is completely loaded, including images, CSS, objects, scripts, frames, and other important resources.

Three important steps:

1st step - DOM is ready.

2nd step - The web page (images, stylesheets etc.) is fully loaded.

3rd step - The event fires.

Is it deprecated ?

Yes, it is deprecated in jQuery version 1.8, and completely removed in 3.0.

This is the old code -

        $(window).load(function () {
            alert("Window Loads");

Is there any new code available, if we want to use newer versions (for example, 3.1.0) of jQuery?

Yes, this is the new code -

$(window).on('load', function () {
      alert("Window Loaded");

Can you give us an example?

Yes. For example, this is our code -

<script src=""></script>

$(window).on('load', function () {
      alert("techntoast image loaded");


<img src="">


javascript window load

What is DOM?

When we open an HTML document in a browser, it creates a DOM structure. Document Object Model is an API (Application Programming Interface) to the web page. We can use various commands and methods to manipulate the DOM. For example, manipulate Elements, Classes, Structure, Attributes etc.

It stands for

D - Document - An HTML Page.

O - Object -  All attributes (href, alt etc.) and elements (<a>, <head>, <body>, <h1>, <h2>...).

M - Model -   A tree structure, which looks like the following graphic:

DOM - Document Object Model

No comments:
Post a Comment