Journal
Font Match
A font pairing app that helps you match fonts – useful for pairing a webfont with a suitable fallback. You can place the fonts on top of each other, side by side, or in the same line. You can adjust your fallback font’s size and position to get a great match.
Font style matcher
If you’re using a web font, you're bound to see a flash of unstyled text (or FOUC), between the initial render of your websafe font and the webfont that you’ve chosen. This usually results in a jarring shift in layout, due to sizing discrepancies between the two fonts. To minimize this discrepancy, you can try to match the fallback font and the intended webfont’s x-heights and widths. This tool helps you do exactly that.
Debouncing vs. throttling with vanilla JS (on Go Make Things)
Chris explains how debouncing and throttling are two related but different techniques for improving performance and user experience when working with frequently invoked JavaScript event handlers.
With throttling, you run a function immediately, then wait a specified amount of time before running it again. Any additional attempts to run it before that time period is over are ignored.
With debouncing, after the relevant event fires a specified time period must pass uninterrupted in order for your function to run. When the time period has passed uninterrupted, that last attempt to run the function is the one that runs, with any previous attempts ignored.
You might debounce code in event handlers for scroll events to run when the user is completely done scrolling so as not to negatively affect browser performance and user experience.
For interactions that update the UI, throttling might make more sense, so that the updates run at predictable intervals.
NB I’ve previously found Trey Huffine’s debounce tutorial and example function really useful, too.
BLOKK - The new and better wireframing font
BLOKK is a font for quick mock-ups and wireframing for clients who do not understand latin.
A cool idea here, which gives you “block” versions of the words in your lorem ipsum text, at the same width.
However at this point I do need to remind myself that designing and wireframing with real content is always better.
Striking a Balance Between Native and Custom Select Elements (on CSS-Tricks)
We’re not going to try to replicate everything that the browser does by default with a native select element. We’re going to literally use a select element when any assistive tech is used. But when a mouse is being used, we’ll show the styled version and make it function as a select element.
This custom-styled select solution satisfies those who insist on a custom component but retains all the built-in accessibility we get from native form controls. I also really like the use of a @media (hover: hover)
media query to detect an environment with hover (such as a computer with a mouse rather than a mobile browser on a handheld device).
Cassie Evans’s Blog
I love Cassie Evans’s new website design! It’s so full of personality while loaded with technical goodies too. Amazing work!
(via @stugoo)
How to use npm as a build tool
Kieth Cirkel explains how using npm to run the scripts
field of package.json
is a great, simple alternative to more complex build tools. The article is now quite old but because it contains so many goodies, and since I’ve been using the approach more and more (for example to easily compile CSS on my personal website), it’s definitely worth bookmarking and sharing.
npm’s scripts directive can do everything that these build tools can, more succinctly, more elegantly, with less package dependencies and less maintenance overhead.
It’s also worth mentioning that (as far as I can tell so far) Yarn also provides the same facility.
Related references:
JavaScript Arrow Functions
JavaScript arrow functions are one of those bits of syntax about which I occasionally have a brain freeze. Here’s a quick refresher for those moments.
Differences between arrow functions and traditional functions
Arrow functions are shorter than traditional function syntax.
They don’t bind their own this
value. Instead, the this
value of the scope in which the function was defined is accessible. That makes them poor candidates for methods since this
won’t be a reference to the object the method is defined on. However it makes them good candidates for everything else, including use within methods, where—unlike standard functions—they can refer to (for example) this.name
just like their parent method because the arrow function has no overriding this
binding of its own.
TL;DR: typical usage
const doStuff = (foo) => {
// stuff that spans multiple lines
};
// short functions
const add = (num1, num2) => num1 + num2;
Explainer
// Traditional Function
function (a) {
return a + 100;
}
// Arrow Function Breakdown
// 1. Remove "function", place => between argument and opening curly
(a) => {
return a + 100;
}
// 2. Remove braces and word "return". The return is implied.
(a) => a + 100;
// 3. Remove the argument parentheses
a => a + 100;
References
How to optimise performance when using Google-hosted fonts (on CSS Wizardry)
A combination of asynchronously loading CSS, asynchronously loading font files, opting into FOFT, fast-fetching asynchronous CSS files, and warming up external domains makes for an experience several seconds faster than the baseline.
Harry Roberts suggests that, while self-hosting your web fonts is likely to be the overall best solution to performance and availability problems, we’re able to design some fairly resilient measures to help mitigate a lot of these issues when using Google Fonts.
Harry then kindly provides a code snippet that we can use in the <head>
of our document to apply these measures.
Modern CSS Solutions
Modern CSS Solutions for Old CSS Problems
Stephanie Eckles with a beautifully presented series of articles on how to use modern CSS to tackle some of the enduring challenges of web development including dropdown navigation, centring and styling buttons.