Optimizes images in quarto-based documents using libvips
to save bandwidth.
This library requires libvips
to be in your path. See their installation instructions to install it on your local machine.
Then,
quarto add abhiaagarwal/optimize-images
This will install the extension under the _extensions
subdirectory.
If you're using version control, you will want to check in this directory.
This extension works by walking the Quarto AST of every single element and when it encounters an image, uses libvips
to generate webp optimized images that will be served on your browser. It also generates multiple copies to be used with responsive images, serving images appropriate for your reader's device.
Thus, you are able to keep your original images in source control while your website deploys optimized copies.
TODO: Add Caching
Here is the source code for a minimal example: example.qmd.