Permalink
Browse files

CSS: Don't name the anonymous swap function

IE8 doesn't like named anonymous expressions. Not naming the function
expression reduces the gzipped size by 5 bytes.

In ECMAScript 2015 the function will get the name inferred from the
variable name (here: swap) anyway.

(cherry-picked from e847574)

Refs 02a9d9f
  • Loading branch information...
mgol committed Jun 1, 2015
1 parent 8e92e1e commit 0019a463bdcb81dc6ba3434505a45774ca27f363
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/css/var/swap.js
View
@@ -1,7 +1,7 @@
define(function() {
// A method for quickly swapping in/out CSS properties to get correct calculations.
return function swap( elem, options, callback, args ) {
return function( elem, options, callback, args ) {
var ret, name,
old = {};

4 comments on commit 0019a46

@markelog

This comment has been minimized.

Show comment
Hide comment
@markelog

markelog Jun 3, 2015

Member

IE8 doesn't like named anonymous expressions

In what way?

Member

markelog replied Jun 3, 2015

IE8 doesn't like named anonymous expressions

In what way?

@dmethvin

This comment has been minimized.

Show comment
Hide comment
@markelog

This comment has been minimized.

Show comment
Hide comment
@markelog

markelog Jun 3, 2015

Member

Yeah i know about this, i was wondering about real implication on our code, i thought it like throws exceptions or something

Member

markelog replied Jun 3, 2015

Yeah i know about this, i was wondering about real implication on our code, i thought it like throws exceptions or something

@mgol

This comment has been minimized.

Show comment
Hide comment
@mgol

mgol Jun 3, 2015

Member

@markelog It doesn't seem to leak for us, I'm not sure if it's because the variable name matches the function name or because we have more than one wrapping function because of the factory defined in intro.js but either way it seems dangerous. Besides, we usually don't name anonymous functions in the jQuery codebase, I accidentally did what I often do in other projects. And since it saves size and in ES6 the built file will effectively have this function named...

Member

mgol replied Jun 3, 2015

@markelog It doesn't seem to leak for us, I'm not sure if it's because the variable name matches the function name or because we have more than one wrapping function because of the factory defined in intro.js but either way it seems dangerous. Besides, we usually don't name anonymous functions in the jQuery codebase, I accidentally did what I often do in other projects. And since it saves size and in ES6 the built file will effectively have this function named...

Please sign in to comment.