DEV Community

Discussion on: 10 years ago: CSS Compression

Collapse
 
maxart2501 profile image
Massimo Artizzu

Class, attribute and id names can surely be mangled, but it's not as easy. They all have impact on HTML and JS (so that's hard to control), and some even on assistive technology (aria-* attributes, anyone?).

On the other hand, why can't we mangle property names and values? Well, of course this wouldn't be valid CSS:

.a {
  d: n;
}

so we have to keep on using display: none instead.

BUT!

We have service workers today. Among the things a service worker can do is to intercept a payload from the server and transform it before it's used by the renderer.
But that would also imply that in the SW we'd have to parse our mangled stylesheet and re-hydrate it to correct CSS. Cumbersome, but at least it's done outside the main thread.

Although inefficiently.

Unless...

Have you folks heard about Houdini's Parser API? With that, the parsing task could be done in a much faster worklet and that could potentially solve everything.