emscripten-core / emscripten-core/emscripten

Use abbreviations for common JS symbols to save on code size

Offen
#20,701 8 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
27.6k
Forks
3.6k
Ø Merge
1 T. 14 Std.
Gemergte PRs (30 T.)
125

Beschreibung

I notices that there are cases where use common JavaScript symbols (e.g. `Object.assign`) multiple times in a single program and non of our current minification passes (including closure compiler) are able to remove or reduce the duplication of these strings.

Admittedly, gzip will can probably do a good job here, but we can't fully depend on that.

I tried creating simple change where I add common abbreviations to `shell.js` e.g.:

```
var assign = Object.assign;
..etc
```

However this has some downsides. Notably:

- It always includes these even if they are not used. We cannot use library dependencies here because some of the usages are in the shell itself which comes before any library symbol is included.
- The usages would all need to be changed from some thing well-known to something not well-known. This decreases maintainability and makes debugging harder. It also means that user-code that uses these symbols would need to be updated too or would not benefit.

Proposed solution: Add a new acorn optimizer pass that can find all the usages of these symbols and inject the abbreviations in the right place.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Lies zuerst shell.js und die vorhandenen JavaScript-Minifizierungspässe und untersuche dann, wie ein Acorn-Optimierungspass Symbolverwendungen durchlaufen würde. Die Arbeit ist abgeschlossen, wenn wiederholt vorkommende häufige Symbole nur dann abgekürzt werden, wenn sie verwendet werden, einschließlich Verwendungen in der Shell und im Benutzercode, ohne manuelle Änderungen am Quelltext zu erfordern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
compilers, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.