google / google/closure-compiler

Missed IIFE inlining opportunity

Open
#1,682 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Given this code:

``` js
(function() {
var $fun;
var $str;
(function() {
$fun = function(a) {
return console.log(a);
};
$str = "hello";
})();
(function() {
$fun($str);
})();
})();
```

It could be inlined all the way to:

``` js
console.log("hello");
```

However, Closure Compiler today only reduces that to:

``` js
(function() {
var a, b;
(function() {
a = function(a) {
return console.log(a);
};
b = "hello";
})();
a(b);
})();
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.