#13759 closed feature (fixed)
Better undefined gzip compression
| Reported by: | m_gol | Owned by: | m_gol |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | build | Version: | 2.0.0-beta3 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description (last modified by )
We can compress better if we tell uglifyjs to not mangle undefined, as suggested by dcherman.
----- ORIGINAL TEXT -----
According to ES5.1, undefined is immutable. All supported in 2.0 browsers besides Android <4.1 (including iOS 5.1 and VERY old Safari) adhere to that.
Removing undefined from the main IIFE parameters saves 62 bytes in the gzipped minified file.
I'm putting it here for a discussion. If we decided to go for that, we also have to decide what to do about 1.x
Change History (14)
comment:1 Changed 5 years ago by
comment:2 Changed 5 years ago by
| Component: | unfiled → build |
|---|---|
| Priority: | undecided → low |
| Status: | new → open |
Even Android?
comment:4 Changed 5 years ago by
Oh, sorry. I don't even know which Android browsers we want to support.
comment:5 Changed 5 years ago by
I guess >= 2.3 currently, unfortunately. :( Anyway, I doubt anyone writes sites only for Android <4.1 so relying on the ability to redefine undefined wouldn't work.
comment:6 Changed 5 years ago by
IE seems to have mutable undefined, after all. I used kangax tables for desktop browsers:
http://kangax.github.io/es5-compat-table/
but they seem to be wrong about IE9.
Anyway, the spec must be more complicated than what I anticipaded. The following code provides the same results in Chrome, Firefox, Opera & IE10 (IE9 results in [0, 1, ..., 7]):
(function ( undefined ) {
console.log( '0: ' + undefined );
})( 0 ); // => 0
(function ( undefined ) {
'use strict';
console.log( '1: ' + undefined );
})( 1 ); // => 1
(function () {
undefined = 2;
console.log( '2: ' + undefined );
})(); // => 2
(function () {
'use strict';
try {
undefined = 3;
console.log( '3: ' + undefined );
} catch (e) {
console.log( '3: ' + e );
}
})(); // => TypeError
(function () {
var undefined = 4;
console.log( '4: ' + undefined );
})(); // => 4
(function () {
'use strict';
var undefined = 5;
console.log( '5: ' + undefined );
})(); // => 5
var undefined = 6;
(function () {
console.log( '6: ' + undefined );
})(); // => undefined
var undefined = 7;
(function () {
'use strict';
console.log( '7: ' + undefined );
})(); // => undefined
comment:8 Changed 5 years ago by
On IRC, dcherman suggested just telling uglify to not compress undefined, which he says saves 40-something bytes. Not quite as much saved, but no downside.
comment:9 Changed 5 years ago by
Yeah... I didn't suspect ES5's meaning of undefined is that you can't do undefined = 'a' but you can do var undefined = 'a'. Sooo helpful...
comment:10 Changed 5 years ago by
| Description: | modified (diff) |
|---|---|
| Summary: | Remove undefined from the main IIFE parameters → Better undefined gzip compression |
comment:11 Changed 5 years ago by
| Owner: | set to m_gol |
|---|---|
| Status: | open → assigned |
Pull request: https://github.com/jquery/jquery/pull/1239
comment:12 Changed 5 years ago by
| Description: | modified (diff) |
|---|
comment:13 Changed 5 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Tell uglifyjs to not mangle undefined; saves 44 bytes. Fixes #13759. Close gh-1239.
Changeset: 8576e24bfe3fce886bcb63ebc24ee16b3fa1a6a1
comment:14 Changed 5 years ago by
BTW, orkel was right, this change actually increases the gzipped 1.x-master size so it makes sense only on master.

+1