Craft Cookies Plugin: Font Loading Detection I'm trying to re-write my font loading detection using the Craft Cookies Plugin. I'm unsure if what I have done is correct...

Before

&lt;!--# if expr="$HTTP_COOKIE=/fonts\-loaded\=1/" --&gt;
&lt;html class="fonts-loaded" lang="{{ craft.app.language |slice(0,2) }}" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"&gt;
&lt;!--# else --&gt;
&lt;html lang="{{ craft.app.language |slice(0,2) }}" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"&gt;
&lt;!--# endif --&gt;


After

{% if getCookie('fonts-loaded') %}
    {% do setCookie('fonts-loaded', fontLoad, now | date_modify("+1 hour").timestamp) %}
    &lt;html class="fonts-loaded" lang="{{ craft.app.language |slice(0,2) }}" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"&gt;
{% else %}
      &lt;html lang="{{ craft.app.language |slice(0,2) }}" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"&gt;
{% endif %}
So I'm not sure what you're accomplishing with this line:

    {% do setCookie('fonts-loaded', fontLoad, now | date_modify("+1 hour").timestamp) %}


I guess trying to give the cookie a longer duration if it was already set? Probably it's best to set the fonts-loaded cookie via JavaScript once FontFaceObserver tells us that the font as been loaded; there's probably no reason to do it here.

FWIW, we can start using the font-display property as a progressive enhancement now to want to eliminate FOUT on modern browsers. Older browsers will still work, but they'll get FOUT: https://caniuse.com/#search=font-display