11ty Logo

Eleventy Edge: Save-Data

← Return to the Full list of Eleventy Edge Demos

Opt-out of web fonts when the Save-Data header is present. You can use a web extension to enable this on your development machine.

Learn more on 11ty.dev: Eleventy Edge Plugin documentation

Source Code


<!-- … -->
{% edge "liquid" %}
{% if eleventy.edge.saveData == false %}
<link rel="preload" href="/static/BenchNine-Bold-subset.woff2" as="font" type="font/woff2" crossorigin>
@font-face {
font-family: BenchNine;
src: url("/static/BenchNine-Bold-subset.woff2") format("woff2");
font-weight: 700;
font-display: swap;
unicode-range: U+21,U+28,U+29,U+2D-3A,U+3F,U+41-5A,U+5F,U+61-7A;
{% endif %}
{% endedge %}
<!-- … -->

Check out the unicode-range value on Uniclode.

Edge Function

No extra edge functions necessary here! eleventy.edge.saveData is a bundled Eleventy Edge feature.