A quarto extension that optimizes your images pre-render #9053
Replies: 2 comments 6 replies
-
This looks like an excellent extension!
I'd love to figure this out, but I'm a bit concerned about the |
Beta Was this translation helpful? Give feedback.
-
Lover our work @abhiaagarwal . After a discussion at #9390 I used your ideas to write an extension to do what you do, but for thumbnails. however! it currently does not work 😢 . nonetheless, it might be interesting. I put some very simple caching logic in. |
Beta Was this translation helpful? Give feedback.
-
Description
Hey folks,
I built an extension that optimizes images on your website before publish. See it here.
Utilizing
libvips
, it generateswebp
copies of your images in multiple sizes to be served. It's done entirely during render and doesn't touch your original files, meaning you can keep the source images in version control and serve optimized ones on your website without using a CDN.I developed this primarily because I was noticing poor lighthouse scores on my personal blog. I try to avoid serving a lot of assets to be cognizant of users with poor internet connections, and also make sure my content is discoverable on search engines. In a page that embedded 4 large images, I was suffering poor metrics.
After introducing this extension on that page, the lighthouse score jumped relatively dramatically.
Give it a shot! I'm not ready to call this production-ready — notably, I haven't implemented a caching solution yet, so your images will be re-rendered on every build. This is not ideal. I'm also not sure whether it works on Windows, as I develop on MacOS. I also would like to add a settings system and support
imagemagick
, which is more popular thanlibvips
.If there's any desire by the quarto team to upstream this, let me know! I'd be more than happy to have this available in the CLI itself.
Beta Was this translation helpful? Give feedback.
All reactions