I use a plugin to do a bunch of optimizations on this site, but for some reason, the preloading of fonts is broken. So I rolled my own font preloading function and placed it in my functional plugin (You could also put it in functions.php). Here’s the code:
// Add code to <head>
function tmm_add_to_header(){
?>
<link rel="preload" href="/path/to/font.woff2" as="font" type="font/woff2" crossorigin>
<?php
};
add_action('wp_head', 'tmm_add_to_header');
That’s it!
Thanks to web.dev for the font preload code.
More posts from themightymo.com
How to change all permalink slugs on a custom post type to “post id” rather than “post title”
Today I needed to change the url slug of a custom post type from /cpt-slug/%post-title%/ to /cpt-slug/%post-id%/. There were thousands of solutions on the web explaining how to change the “cpt-slug” portion of the url, but I couldn’t find a simple solution to change the last part of the url. Well here it is! The…
My Main Issue with Clickup
Clickup integrates with everything. It’s simple to use. But there’s one thing that drives me crazy: Their user interface (UI) assumes the conversation we have around to-dos is NOT important. Clickup‘s UI assume the task writeup stuff (uploaded docs, description, links, etc.) is more important than the conversation about that stuff. In my experience, the…
How to merge two folders, including all sub-folders and files, on Mac
Today I had an issue where I needed to merge two folders, each of which contained many sub- and sub-sub folders that had lots of images. After a lot of trial-and-error and some Googling, I found the best solution is to use the “ditto” command in Terminal like this: That’s it! Hat tip to AppleInsider.