vendredi 25 juin 2021

Best choice between network optimisation and CPU usage in clientside web development

I'm working on a CSS library that includes hundreds of selectors and rules for quick templating instead of writing regular CSS. This is used as a replacement of attr() CSS function until it works for any rule and not just content:.

At first I generated a minified CSS file to load. But as there are many loops for each possible values, I've been trying to generate those CSS rules directly in the browser instead.

Here is a sample of a performance result:

  • Prebuilt CSS file : 150KB / 15ms script CPU usage
  • JS file (injecting in <style> element) : 20KB / 150ms script CPU usage

Of course those results can vary a lot depending on the network and the device. But in overall, what would be the best choice between network optimisation and CPU optimisation (for any kind of device)?




Aucun commentaire:

Enregistrer un commentaire