-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Reduce build size by 33% #1756
Reduce build size by 33% #1756
Conversation
lighthouse-extension/gulpfile.js
Outdated
@@ -155,6 +162,33 @@ gulp.task('browserify', cb => { | |||
runSequence('browserify-lighthouse', 'browserify-other', cb); | |||
}); | |||
|
|||
gulp.task('compilejs', () => { | |||
const opts = { | |||
mangle: false, // Preserve array notation property access. Needed for artifact name lookups. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting how does this disrupt array notation specifically? I had thought mangle was fine unless Function.name
/with
/eval
though I'm not familiar with uglify-harmony gotchas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right because we do use Function.name
there with the gatherer class name, maybe update that comment then? The accessors seems like the secondary issue to the primary problem of the gatherer being renamed :)
In lighthouse/lighthouse-core/scripts/build-traceviewer-module.js Lines 134 to 138 in 7a5448e
are you open to using that? this way we wouldn't have to deal with disabling a bunch of options like mangle and sideEffects. |
For the life of me, I couldn't get babel, typescript, or closure to play nicely.
In terms of filesize reduction, I didn't find disabling a few compressor settings to adversely effect file size that much. |
lighthouse-extension/gulpfile.js
Outdated
compress: { // turn off a bunch stuff so we don't create unexpected errors. | ||
unused: false, | ||
properties: false, | ||
dead_code: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't dead code supposed to be caught by ESLint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it does, we're not running eslint over the browserified bundle.
I put up #1765 which replaces uglify with babel. It has one benefit of not adding any new dependencies at all. :) |
R: all
In this spirit of #1690, I've managed to get the build down to 1.6MB. 33% savings!
Other low hanging fruit is stripping out the html/js license comments in the inlined files (
readFileSync
).This PR introduces uglify-harmony into the extension gulpfile.
gulp build:production
will build lighthouse-extension.js and also compress it.gulp build
continues to only broswerify. I felt that we may still want to keep that around for speedlier development when making tweaks to the crx. Happy to consolidate though.