Question

In using this cool onload function from JQuery

$(document).ready(function(){ // my stuff }

do I need to worry about overwriting anything else that may have called it?

Was it helpful?

Solution

@OneNerd is right in his answer that it just adds to the ready queue. The ready method is declared in jQuery like this:

ready: function( fn ) {
    // Attach the listeners
    jQuery.bindReady();

    // Add the callback
    readyList.add( fn );

    return this;
},

Ref: http://code.jquery.com/jquery.js

OTHER TIPS

In jQuery, that function adds to the ready queue I believe, so you can write multiple ready() functions without worrying about overwriting previous ones (they just stack).

$(document).ready is an event, so as many subscribers as you want can wire up to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top