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?
$( document ). ready() A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ). ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute.
load(function(){ // ...}) @undefined, this is almost the same as $(document). ready(function(){ ... }) . load() will wait until the graphics are also loaded.
Yes we can do it as like I did in below example both the $(document). ready will get called, first come first served.
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).
@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
$(document).ready is an event, so as many subscribers as you want can wire up to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With