One of the biggest downloads when requesting a web page is custom fonts. There are many good techniques for lazy loading fonts that improve performance when you have a poor connection. By knowing which fonts are available to your users, you can avoid loading custom fonts.there queryLocalFonts
Introducing native JavaScript functions to collect user font information.
queryLocalFonts
is async
This feature requires user permission via a browser prompt the first time it runs. queryLocalFonts
returns an array of FontData
An object containing information about all available fonts:
const localFonts = await window.queryLocalFonts(); // [FontData, FontData, ...] /* family: "Academy Engraved LET", fullName: "Academy Engraved LET Plain:1.0", postscriptName: "AcademyEngravedLetPlain", style: "Plain", */
You can also query the font face directly if you want to target a specific font face. postscriptName
property:
const canelaFonts = await window.queryLocalFonts( postscriptNames: ["Canela", "Canela-Bold"], ); // [FontData, FontData, ...]
and queryLocalFonts
Instead of downloading expensive custom fonts, you can leverage the fonts you already own. However, the permission prompt seems to prevent the user from authorizing the API. It’s great that this API exists.
LightFace: Facebook Lightbox for MooTools
One of my all-time favorite web components is Facebook’s modal dialog. This “light box” is different from others. No dark overlays, no annoying size-adjusting animations. Also, don’t try to do “too much”. We created LightFace, a Facebook lightbox, with Facebook dialogs in mind.
How to create a RetroPie on Raspberry Pi – Graphical Guide
Today, we can play great games on super-powered consoles, PCs, VR headsets, and even mobile devices. Lately, I’ve been enjoying playing new games, but I also long for the retro game consoles I had when I was a kid, the original Nintendo.
jQuery random link color animation
We all know you can set a :hover color for a link, but what if you want to add a little more dynamism and flair? With jQuery, you can not only animate to a color you specify, but also animate to a random color. It can also be animated. of…
Introducing MooTools Dotter
It’s a best practice to provide some kind of indicator when performing AJAX requests or processing that happens in the background. Since the early days of AJAX, we’ve been using colorful spinners and images as indicators. While enjoying such images, I…