owid-grapher icon indicating copy to clipboard operation
owid-grapher copied to clipboard

Asset optimization (image, CSS, JS)

Open mlbrgl opened this issue 2 years ago • 3 comments

Capturing suggestions made by an external contributor that came through https://github.com/owid/owid-issues/issues/370:

  • Make enormous images (timeglass etc.) smaller and/or optimize using e.g. ImageOptim. I could reduce the file size of these by more than 40% just by lossless optimization, no resizing. This is rather general and could be used to improve other pages as well.
  • Make sure all minify and compress options are enabled in Netlify. If the combine JS/CSS options are disabled, enabling them would give a speed boost too, but has to be done carefully and preferably tested in a staging environment first. (Combining files can cause trouble if you’re unlucky.) This is site-wise and could give a speed boost to the entire website.

mlbrgl avatar May 16 '22 17:05 mlbrgl

How much effort do you think both of these points would take?

The sense from DanielB & I is that the first one could be tackled quickly, but that the second could gradually blow out. Appetite would be less than 3d I think.

larsyencken avatar May 17 '22 10:05 larsyencken

@larsyencken I don't think the ratio risk/reward is in favour of pushing the CSS / JS further along those lines, given that:

  • we're already minifying and concatenating through webpack
  • we're serving 3 JS / 2 CSS files
  • requests are multiplexed through http/2

On the PNG front, we are hosting ~ 20K PNG,

$ find bakedSite/ -name \*.png | wc -l
21100

but only serving about ~ 230 "large" PNGs (by Google's definition and count).

Screenshot 2022-05-17 at 17 43 13

I'm expecting these to be largely Wordpress images (since grapher exports are 850px wide, and not "google-large"). All Wordpress images are rendered through srcset responsive optimizations (although they haven't been really fined tuned).

All in all, I'm not expecting a large gain from a bandwidth perspective (but maybe this google search approximation is not very representative). On the other hand, I don't think there is much risk turning on looseless compression on Netlify (effort should be less than an hour, most of the time spent on looking side-effects).

Screenshot 2022-05-17 at 17 58 55

mlbrgl avatar May 17 '22 16:05 mlbrgl

Ah, interesting. Ok, sounds like maybe the Netlify option is the only one worth trying then.

larsyencken avatar May 17 '22 20:05 larsyencken

This issue has had no activity within 10 months. It is considered stale and will be closed in 7 days unless it is worked on or tagged as pinned.

github-actions[bot] avatar Aug 11 '23 07:08 github-actions[bot]

We expect to migrate to CloudFlare Images, so we won't do more here in the meantime.

larsyencken avatar Aug 14 '23 10:08 larsyencken