Skip to content
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

An edge case is not covered in minification-estimator.js #15621

Closed
2 tasks done
avinash-sd opened this issue Nov 17, 2023 · 3 comments
Closed
2 tasks done

An edge case is not covered in minification-estimator.js #15621

avinash-sd opened this issue Nov 17, 2023 · 3 comments
Assignees

Comments

@avinash-sd
Copy link
Contributor

FAQ

URL

https://example.com

What happened?

While checking lighthouse reports, I noticed abnormally large Potential Savings size in minify JS opportunity for a javascript file that is minified already.

What did you expect?

I expected the lighthouse report to not list minified JS files in this minify JS opportunity.

What have you tried?

I inspected the code of minification-estimator.js with that JS file I have encountered with this problem. Turns out that the file contained this patch of code in middle of the file:
else/VALID_REGEX_PATTERN/.test(n)?(d=(new DOMParser).parseFromString("...
When the loop hit the /VALID_REGEX_PATTERN/, it doesn't consider it as a regex and the subsequent totalTokenLength calculation is messed up.

I added else in PUNCTUATOR_REGEX variable in minification-estimator.js, then it worked fine.

How were you running Lighthouse?

node

Lighthouse Version

11.1.0

Chrome Version

No response

Node Version

No response

OS

No response

Relevant log output

No response

@connorjclark
Copy link
Collaborator

Wow, very impressive code sleuthing! Thanks for sharing your fix. Happy to commit it myself, but would you like to do the honors? No worries if not.

@avinash-sd
Copy link
Contributor Author

Yeah sure! I like to do it myself 😇

@avinash-sd
Copy link
Contributor Author

Issue resolved! #15624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants