Internet Resource

Preload Featured Images to Improve Google CLS Score

If you use featured images on the first screen of your site, the large feauted may affect your Google pagespeed socre, inorder to repload the image, you can use the following code to preload the images, in order to get a higher score.

Copy and paste it to your theme’s funcion.php file.

add_action( 'wp_head', function(){
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); 
echo '<link rel="preload" as="image" href="'.$featured_img_url.'"/>';