Reputation: 6825
I have ran Google Page Speed Insights and their main suggestion is to minify js
file with over 70% of savings (from 423 KB to 312 KB to be exact) which is insane.
But the file is minified! What am I missing?
Resources:
P.S. I have gone through other similar questions on SO and neither were similar to my problem.
Upvotes: 2
Views: 1150
Reputation: 21
I'd recommend skimming your minified file and looking for human readable JS tokens.
From what I can see, the test is mainly looking at JS tokens length.
/**
* @fileOverview Estimates minification savings by determining the ratio of parseable JS tokens to the
* length of the entire string. Though simple, this method is quite accurate at identifying whether
* a script was already minified and offers a relatively conservative minification estimate (our two
* primary goals).
*
* This audit only examines scripts that were independent network requests and not inlined or eval'd.
*
* See https://github.com/GoogleChrome/lighthouse/pull/3950#issue-277887798 for stats on accuracy.
*/
If you see human readable tokens in your minified file, try looking at your minifier settings to see if there is an option you can toggle that gets rid of these.
If there is no setting that gets rid of them, try identifying where these are coming from and how they are different than other tokens that are minified successfully. The culprit might be a coding pattern, framework, or transpiler.
Note: The source code is linked from their help page (https://web.dev/unminified-javascript/)
Upvotes: 2
Reputation: 1753
It can give you a very high level view of massive issues but once you start to optimise things, it falls short. It believes your js file is large and that minimising it will help. It can't actually tell that you have minimised it already.
I once had it tell me to use gzip compression for a single, cached 2k SVG file. Another time, it asked me to shrink the 200 or so tiny 12k jpegs that a site was using. Its not very clever - in the first case it was wasting my time, and in the second case there was a better answer (use sprite sheets) but its unable to look that deeply.
Upvotes: 2