Sometimes a report from Lighthouse will indicate you should preload a resource. Adding this (and replacing the href
, and making sure you use the correct as=
value) to your theme’s functions.php file will preload a resource.
function lx_preload() {
?>
<link rel="preload" href="/wp-content/themes/Avada/includes/lib/assets/fonts/icomoon/icomoon.woff" as="font" crossorigin>
<?php
}
add_action( 'wp_head', 'lx_preload', 5);
Note that in the case of fonts, the cross-origin attribute is required, even if the file is not actually cross-origin.