Seems Like There's Effectively No Difference Parsing Minified CSS vs. Non - Minified
I ran a few samples pulling timing data for page loads in an attempt to tell if there was a difference between page load times with Minified vs. Non - Minified CSS. I wasn't able to identify one with my limited data run.
Based on > this Constructing the Object Model > https : //web.dev/articles/critical - rendering - path/constructing - the - object - model > post it looks like the only difference between the two would be lexing the characters into tokens. Someone with more resources will have to dig further into the weeds to see difference there.
Notes And Methodology
-
This is an attempt to see if there's a difference between the parsing times of a minified vs non - minified CSS file
-
It's tough to figure out exactly what to look for. The data I'm using is "domLoading", "domInteractive", "domContentLoaded", and "domComplete" from my Vivaldi browser's Navigation Timing API
-
My hypothesis based on the diagram on the > MDN Navigation and resource timings page > https : //developer.mozilla.org/en - US/docs/Web/Performance/Navigation _ and _ resource _ timings page > is that the CSS processing and creating of the > CSS Object Model > https : //developer.mozilla.org/en - US/docs/Web/Performance/Critical _ rendering _ path#css _ object _ model > is that the creation of the CSSOM happens in - between domLoading and domInteractive (along with a bunch of other stuff)
-
All this work happens after the file is received which should mean network times are taken out of it. I'm taking this approach to limit things to one variable at a time
-
Times have a resolution of milliseconds via the > DOMHighResTimeStamp > https : //developer.mozilla.org/en - US/docs/Web/API/Performance _ API/High _ precision _ timing#domhighrestimestamp >
-
This is only 5 runs per file type. That's not much. It was all manual and I don't have a non - trivial way to do a bigger run. Take it for what it's worth
-
The test files used were the [TODO: Code shorthand span ] and [TODO: Code shorthand span ] file which weigh in at 245,486 bytes and 207,302 bytes respectively
-
I'm not using any of the styles from the CSS, but based off this > Constructing the Object Model > https : //web.dev/articles/critical - rendering - path/constructing - the - object - model > post I expect that is effectively irrelevant. According to that page, by the time rendering happens everything has been converted into object
-
That page also points to the idea only real difference in timing would be lexing from the characters to the tokens
-
I ran the HTML file off localhost and called the CSS files externally in order to use a server that compressed them with brotli
-
The raw (non - minified) version of the file had domLoading to domInteractive times between 224 and 333ms. The minified version was 241 to 279ms
-
That makes me think that for my human level of processing any difference would be washed out by jitter across the rest of the system.
-
The raw is up top if you want to play with it. The results are below the data and code
The Data And Results
=
= -
= -
= -
Legend
-
L - I = domLoading to domInteractive
-
I - CL = domInteractive to domContentLoadedEventStart
-
CL - C = domContentLoadedEventStart to domComplete