Another thing is splicing unecessary properties, which can even save more bytes, but given web apps becoming becoming so dynamic right now, that would be hard or really awkward for developer to work with too.
Another thing is splicing unecessary properties, which can even save more bytes, but given web apps becoming becoming so dynamic right now, that would be hard or really awkward for developer to work with too.
The programmer could shorten it when writing, but is the extra half a milisecond worth having to work with x, y and z as classes rather than more explicit classes?
If that's the case, using CSS Modules, you can do in CSS:
.list-1 { ... }
.list-2 { ... }
requiring it will yield a map like this: { 'list-1': 'JSNF4S12', 'list-2': 'IE945JSN' }
which you can use this way: const styles = require('file.css');
$('.' + styles[`list-${i}`])
// effectively $('.JSNF4S12')In fact this is how gettext() works.
the other option is what CSS modules does. your scripts essentially "require" classnames from your stylesheets so as classnames in your stylesheet are minified so are their js references.
CSS Modules [1] and other tools allow you to require CSS like you would with any other dependency, and replace named classes by unique hashes at build time. This prevents your CSS from leaking to elements that do not explicitly require it.