Extension for the static-site generator Grow that enables asset preloading from within partials
This extension comes in handy if you want add preload tags for critical assets. See https://web.dev/preload-responsive-images/
- Create an
extensions.txt
file within your pod. - Add to the file:
git+git://github.com/jungvonmatt/grow-ext-preload-assets
- Run
grow install
. - Add the following section to
podspec.yaml
:
ext:
- extensions.inline_text_assets.PreloadAssetsExtension
This configuration a bundle to your documents that can be used in your templates with for example
{%- do doc.preload.addAsset({
'src': 'wolf.jpg',
'srcset': 'wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w'
'sizes': '50vw'
}) -%}
{% endif %}
<head>
{{ doc.preload.emit() }}
...
<head>
<link rel="preload" as="image" href="wolf.jpg" imagesrcset="wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w" imagesizes="50vw">