Tuesday, April 30, 2024
HomeTechnologySoftwareDetecting Fonts Ready

Detecting Fonts Ready

Date:

Related stories

Sarah Hudson Pierce: The effects of sleep deprivation

According to the CDC thirty -six percent or...

Free Printable To-Do List Template

Last updated: April 29, 2024 by the Homemade...

19 Neat Games We Saw At Xbox’s Big Indie Showcase

Microsoft is still working hard to court indie...

Tapping into the Power of Purpose to Engage Students

Having a purpose comes with benefits, according to...

2025 BMW M5 rumored to make 718 horsepower, that’s the good news

More intel courtesy of BMW whisperer ynguldyn, an...
spot_imgspot_img

Knowing when resources are loaded is a key part of building functional, elegant websites. We’re used to using the DOMContentLoaded event (commonly referred to as “domready”) but did you know there’s an event that tells you when all fonts have loaded? Let’s learn how to use document.fonts!

The document.fonts object features a ready property which is a Promise representing if fonts have been loaded:

// Await all fonts being loaded
await document.fonts.ready;

// Now do something!  Maybe add a class to the body
document.body.classList.add('fonts-loaded');

Font files can be relatively large so you can never assume they’ve loaded quickly. One simply await from document.fonts.ready gives you the answer!

  • Welcome to My New Office

    My first professional web development was at a small print shop where I sat in a windowless cubical all day. I suffered that boxed in environment for almost five years before I was able to find a remote job where I worked from home. The first…

  • 5 Awesome New Mozilla Technologies You’ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible.  I’ve spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out.  MozSummit provided the perfect reminder of how brilliant my colleagues are and how much…



Source link

Latest stories

spot_img