-
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
core(unminified-javascript): replace esprima with custom tokenizer #5925
Conversation
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.
Personally think this is a good direction to go, particularly since we're only interested in testing such a superficial level of minification anyways.
It would be cool to be able to guess at local variable names and replace them with minified versions to really approximate the baseline level uglify/whatever minification of JS, but not as important and just more state to track.
Anecdotal testing I've done so far is run on a couple sites and make sure the % savings are the same for each file.
Post these once you're more seriously tackling this?
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.
hot. lgtm
some stats from runs, byte numbers are LH-reported savings, the usual culprits have gone and fixed their minification savings I used to find (yay!), so if you've got good examples, happy to have them :)
Instead I used a few libraries during my testing, here's the results
|
@brendankenny @exterkamp how is this lookin' to you folks? fine if no opinion, just a bit on the big side to expect no comments ;) |
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.
LGTM! This is great. Bundle size goes way down.
Since we'll fully control this tokenizer (and likely not change it much), it does feel like we could run it over largish files and get repeatable results without much test churn, but I don't have a good suggestion for candidates for this (files under our control we have, but not ones we change so rarely that they'd function as good canaries...)
we could bring in a dev dependency at a fixed version that we won't ever be using, but could use the contents entirely for smoke testing the CSS/JS tokenizer... |
I like it. What's the biggest, most complex front end dependency we can think of? :) |
Oh sorry! Was waiting on ideas for smoke test :) Will do angular in a follow-up if no other suggestions. |
sg
|
ha, oh yeah, sorry! |
Summary
Removes dependency on esprima for JS minification savings and replaces it with a custom scanner/token counter similar to our CSS one. Putting this up for discussion before hardening it and going down the edge case rabbit hole.
Pros
Cons
Anecdotal testing I've done so far is run on a couple sites and make sure the % savings are the same for each file.
Related Issues/PRs
fixes #5723