diff options
author | John Resig <jeresig@gmail.com> | 2007-12-10 01:45:03 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2007-12-10 01:45:03 +0000 |
commit | f97f77c034dc62001a687c728bdfdc71a23bf6b8 (patch) | |
tree | 915e014284d246a0392cf357fa4a0ebbb58b7605 /src | |
parent | ccf055033ab165c677590b42fa0ca7e0a29e9fb7 (diff) | |
download | jquery-f97f77c034dc62001a687c728bdfdc71a23bf6b8.tar.gz jquery-f97f77c034dc62001a687c728bdfdc71a23bf6b8.zip |
Added a change that triples the speed of all uses of $(...). For example $(DOMElement) was 38ms, is now 13ms.
Diffstat (limited to 'src')
-rw-r--r-- | src/core.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core.js b/src/core.js index 27a57283e..39ffdb580 100644 --- a/src/core.js +++ b/src/core.js @@ -14,10 +14,8 @@ if ( window.jQuery ) var _jQuery = window.jQuery; var jQuery = window.jQuery = function( selector, context ) { - // If the context is a namespace object, return a new object - return this instanceof jQuery ? - this.init( selector, context ) : - new jQuery( selector, context ); + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.prototype.init( selector, context ); }; // Map over the $ in case of overwrite @@ -521,6 +519,9 @@ jQuery.fn = jQuery.prototype = { } }; +// Give the init function the jQuery prototype for later instantiation +jQuery.prototype.init.prototype = jQuery.prototype; + function evalScript( i, elem ) { if ( elem.src ) jQuery.ajax({ |