]> source.dussan.org Git - jquery.git/commitdiff
Reduce size by reordering variable declarations
authorChris Antaki <ChrisAntaki@gmail.com>
Wed, 6 Nov 2013 05:23:04 +0000 (21:23 -0800)
committerRichard Gibson <richard.gibson@gmail.com>
Mon, 16 Dec 2013 17:48:46 +0000 (12:48 -0500)
Close gh-1421

src/attributes/classes.js
src/core/access.js
src/effects.js
src/traversing/findFilter.js

index d7212f9dee2dcc18f084d7df8f417b80846ded5a..7d714b8e1f1be6e26bedfbee085245516d632e36 100644 (file)
@@ -11,9 +11,9 @@ var rclass = /[\t\r\n\f]/g;
 jQuery.fn.extend({
        addClass: function( value ) {
                var classes, elem, cur, clazz, j, finalValue,
+                       proceed = typeof value === "string" && value,
                        i = 0,
-                       len = this.length,
-                       proceed = typeof value === "string" && value;
+                       len = this.length;
 
                if ( jQuery.isFunction( value ) ) {
                        return this.each(function( j ) {
@@ -54,9 +54,9 @@ jQuery.fn.extend({
 
        removeClass: function( value ) {
                var classes, elem, cur, clazz, j, finalValue,
+                       proceed = arguments.length === 0 || typeof value === "string" && value,
                        i = 0,
-                       len = this.length,
-                       proceed = arguments.length === 0 || typeof value === "string" && value;
+                       len = this.length;
 
                if ( jQuery.isFunction( value ) ) {
                        return this.each(function( j ) {
index 97b410b40a5a080b50924f4cf151236f5a5a7082..b6110c8f31c1c16f348267eb3e48d08b9597c03c 100644 (file)
@@ -6,7 +6,7 @@ define([
 // The value/s can optionally be executed if it's a function
 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
        var i = 0,
-               length = elems.length,
+               len = elems.length,
                bulk = key == null;
 
        // Sets many values
@@ -40,7 +40,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
                }
 
                if ( fn ) {
-                       for ( ; i < length; i++ ) {
+                       for ( ; i < len; i++ ) {
                                fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
                        }
                }
@@ -52,7 +52,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
                // Gets
                bulk ?
                        fn.call( elems ) :
-                       length ? fn( elems[0], key ) : emptyGet;
+                       len ? fn( elems[0], key ) : emptyGet;
 };
 
 return access;
index cbf098d1a5f19b7956ec933dd67f857d7261b603..b439d8d58dfee4006233d76fc677087fc1f45d95 100644 (file)
@@ -82,8 +82,8 @@ function createFxNow() {
 // Generate parameters to create a standard animation
 function genFx( type, includeWidth ) {
        var which,
-               attrs = { height: type },
-               i = 0;
+               i = 0,
+               attrs = { height: type };
 
        // if we include width, step value is 1 to do all cssExpand values,
        // if we don't include width, step value is 2 to skip over Left and Right
@@ -590,8 +590,8 @@ jQuery.each({
 jQuery.timers = [];
 jQuery.fx.tick = function() {
        var timer,
-               timers = jQuery.timers,
-               i = 0;
+               i = 0,
+               timers = jQuery.timers;
 
        fxNow = jQuery.now();
 
index 71fe52aaf4f7ef63f55f56f6eb29d1d449208a9b..f903ac715347b7cc0b89e49d57011453ed7c57d1 100644 (file)
@@ -53,14 +53,14 @@ jQuery.filter = function( expr, elems, not ) {
 
 jQuery.fn.extend({
        find: function( selector ) {
-               var i,
+               var i = 0,
+                       len = this.length,
                        ret = [],
-                       self = this,
-                       len = self.length;
+                       self = this;
 
                if ( typeof selector !== "string" ) {
                        return this.pushStack( jQuery( selector ).filter(function() {
-                               for ( i = 0; i < len; i++ ) {
+                               for ( ; i < len; i++ ) {
                                        if ( jQuery.contains( self[ i ], this ) ) {
                                                return true;
                                        }
@@ -68,7 +68,8 @@ jQuery.fn.extend({
                        }) );
                }
 
-               for ( i = 0; i < len; i++ ) {
+               i = 0;
+               for ( ; i < len; i++ ) {
                        jQuery.find( selector, self[ i ], ret );
                }