8000 Lose 70KB with One Weird Trick! Doctors hate it! · Issue #5293 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

Lose 70KB with One Weird Trick! Doctors hate it! #5293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
robwormald opened this issue Nov 15, 2015 · 12 comments
Closed

Lose 70KB with One Weird Trick! Doctors hate it! #5293

robwormald opened this issue Nov 15, 2015 · 12 comments
Labels
area: performance Issues related to performance

Comments

@robwormald
Copy link
Contributor

Typescript emits an __extends helper to, well, help with extending classes.

It currently shows up a few dozen times in our codebase, turning it off in the broccoli tree saves ~70KB unminified / 44KB minified in the existing System bundles.

option is noEmitHelpers: true

Same optimization in Rx saves ~20KB or so, will submit a PR over there as well.

We'll need to include it at least once, of course, so this might be best added into our proposed "ngPolyfill" along with Reflect?

cc @IgorMinar

@robwormald robwormald added this to the beta-00 milestone Nov 15, 2015
@robwormald robwormald added area: performance Issues related to performance P1: urgent labels Nov 15, 2015
@IgorMinar
Copy link
Contributor

We shouldn't leak these helpers outside of our bundles otherwise we could run into conflicts with other people doing the same.

What we should do instead is include helpers only once within each bundle.

IMO this can be done post beta because it doesn't change API surface, but if someone really wants to implement this before beta then I'm not going to stand in their way.

@mhevery mhevery modified the milestones: beta-01, beta-00 Nov 15, 2015
@pkozlowski-opensource
Copy link
Member

@robwormald did you measure things with min+gzip? I was assuming that with gzip the actual gains (in terms of size) would be much smaller.

For me the biggest pb here is that TS doesn't give us a file with all the helpers it can produce (we don't have any equivalent of traceur-runtime).

@bradlygreen
Copy link
Contributor

Even if it isn't much smaller, savings in JS parse time will still be good to have.

@mhevery mhevery modified the milestones: beta.01, beta.02 Jan 25, 2016
@pkozlowski-opensource
Copy link
Member

tl;dr; using min+gzip numbers we can see that we can save only ~2kB (< 2%) using this trick.

Here are exact numbers on what we can save for a simple "Hello World" application (see diff of what had to be changed to package helpers only once):

WebPack SystemJS
Before (bytes) 112 045 161 544
After (bytes) 110 011 159 402
Diff (bytes) -2 034 (~2kB) -2 142 (~2.1kB)
Diff (%) -1.82% -1.33%

Impact on the load time is harder to see: during my naive measures I couldn't see significant and consistent improvement.

@pkozlowski-opensource
Copy link
Member

If we want to implement this trick, here is a TODO list:

This would be a breaking change for people that bundle things on their own and don't use angular2-polyfills.js

@IgorMinar
Copy link
Contributor

TS is going to ship helpers as a separate npm package. There is an issue
for 1.8 by @mhegazy about this.
On Tue, Jan 26, 2016 at 5:58 AM Pawel Kozlowski notifications@github.com
wrote:

If we want to implement this trick, here is a TODO list:

This would be a breaking change for people that bundle things on their
own and don't use angular2-polyfills.js


Reply to this email directly or view it on GitHub
#5293 (comment).

@mhegazy
Copy link
Contributor
mhegazy commented Jan 26, 2016

the issue tracking this is microsoft/TypeScript#3364; along with that we should have a tslib npm package that has all the known helpers along with some .d.ts for them. This will not be in TS 1.8, but we should have it out soon though. using --noEmitHelpers should work in the mean time.

@mhevery mhevery modified the milestone: beta.02 Jan 26, 2016
@Hotell
Copy link
Hotell commented Apr 17, 2016

Don't know if this is still valid issue, but in the meantime, you can use https://github.com/ngParty/ts-helpers

@vicb vicb closed this as completed Jul 29, 2016
@imcotton
Copy link
Contributor

@vicb
Since Angular v4 heading to TypeScript v2.1, I think it's good time to revisit this ticket, with combining of noEmitHelpers and importHelpers (via dependency of tslib) flags.

@PFight
Copy link
PFight commented Mar 8, 2017

@vicb Right now, Im having over 60+ __extends methods in my result bundle. Vote to open this issue again. Angular is very big, why dont to make it a bit smaller from nothing?

@IgorMinar
Copy link
Contributor
IgorMinar commented Mar 9, 2017 via email

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: performance Issues related to performance
Projects
None yet
Development

No branches or pull requests

0