aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-08-22 06:51:41 +0000
committerJohn Resig <jeresig@gmail.com>2007-08-22 06:51:41 +0000
commitf53aa62fd3f08ad7a05e99e3836132216a8d5c7d (patch)
treeef0e2ee722a0f86a26a732acb71d8204fee49111 /src
parent3fb4779abbd4c8b12efda6a5648da8a7e002cab2 (diff)
downloadjquery-f53aa62fd3f08ad7a05e99e3836132216a8d5c7d.tar.gz
jquery-f53aa62fd3f08ad7a05e99e3836132216a8d5c7d.zip
Only bind .ready() once per instance of jQuery - and only bind if the ready() method is actually called (nothing is bound if window/load is used).
Diffstat (limited to 'src')
-rw-r--r--src/event/event.js12
-rw-r--r--src/intro.js3
2 files changed, 12 insertions, 3 deletions
diff --git a/src/event/event.js b/src/event/event.js
index 2d007117a..a4a99d99c 100644
--- a/src/event/event.js
+++ b/src/event/event.js
@@ -529,6 +529,9 @@ jQuery.fn.extend({
* @see $(Function)
*/
ready: function(f) {
+ // Attach the listeners
+ bindReady();
+
// If the DOM is already ready
if ( jQuery.isReady )
// Execute the function immediately
@@ -928,7 +931,13 @@ jQuery.extend({
};
});
-
+
+var readyBound = false;
+
+function bindReady(){
+ if ( readyBound ) return;
+ readyBound = true;
+
// If Mozilla is used
if ( jQuery.browser.mozilla || jQuery.browser.opera )
// Use the handy event callback
@@ -974,3 +983,4 @@ jQuery.extend({
// A fallback to window.onload, that will always work
jQuery.event.add( window, "load", jQuery.ready );
+}
diff --git a/src/intro.js b/src/intro.js
index 9c2f985eb..af50383ec 100644
--- a/src/intro.js
+++ b/src/intro.js
@@ -1,2 +1 @@
-// prevent execution of jQuery if included more than once
-if ( typeof jQuery == "undefined" ) (function(){
+(function(){