However, there may be times when you need to write scripts in the load() method. For instance, to determine the true width and height of a picture.
Once the DOM, CSS, pictures, and frames are entirely loaded, the $(window).load event is called. As a result, it is the optimal area to write jQuery code to determine the real picture size or to obtain information about anything.
| When a function needs to be made available after the document has loaded, use the ready() method. Whatever code you include in the $(document).ready() method will be executed once the DOM of the page is prepared to run JavaScript code. |