Skip to content

IE8 and named function expressions #248

@alexindigo

Description

@alexindigo

There is interesting thing happening in IE8:

Example 1:
<script>
var a = {};
</script><script>
var xx = function a() {};
alert(typeof a);
</script>

Example 2:
<script>
var b = {};
var zz = function b() {};
alert(typeof b);
</script>

In Webkit, Gecko and IE9 result will be "object" in both cases, in IE8 you'd see "function" in first example and "object" in second.

And with mangle mode in uglify, it will mangle names of the function expressions which would have no effect, so it could actually remove them and save few extra bytes. Or at least it would be nice when --screw-ie8 is false to respect options like -d "x" and -r "x" and not use x (for example) for mangled names.

Real world use case:

  • Global object x.
  • Module with standard pattern:
function Bla() {}
Bla.prototype.method = function Bla_uniqueNameForDebuggingPurpose() {}

which looks like that after minifying:

function Bla() {},Bla.prototype.method = function x() {}

and overrides x in IE8 and IE9 (in quirks mode).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions