Home > Web Front-end > JS Tutorial > Comparison between the execution timing of the ready() function in jquery and the load event of the window_jquery

Comparison between the execution timing of the ready() function in jquery and the load event of the window_jquery

WBOY
Release: 2016-05-16 15:53:35
Original
1115 people have browsed it

jquery’s ready() implements the DOMContentLoaded event. The difference between DOMContentLoaded and window load events

To put it simply, ready() is triggered when the document is loaded. At this time, images and other resources may not be fully loaded. load is triggered after all resources are loaded

If you look at the code of the ready function, everything will be clear. The code below is commented:

// Handle when the DOM is ready
    ready: function() {
        // Make sure that the DOM is not already loaded
        if ( !jQuery.isReady ) {
            // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
            if ( !document.body ) {
                return setTimeout( jQuery.ready, 13 );
            }

            // Remember that the DOM is ready
            jQuery.isReady = true;

            // If there are functions bound, to execute
            if ( readyList ) {
                // Execute all of them
                var fn, i = 0;
                while ( (fn = readyList[ i++ ]) ) {
                    fn.call( document, jQuery );
                }

                // Reset the list of functions
                readyList = null;
            }

            // Trigger any bound ready events
            if ( jQuery.fn.triggerHandler ) {
                jQuery( document ).triggerHandler( "ready" );
            }
        }
    },
Copy after login

The above is the entire content of this article, I hope you all like it.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template