## plugins – is there a way to preload specific images for desktop users only? (excluding mobile users)

Question

My website has a few .PNG images animated at the very start of my Contact page.
Those images are a bit heavy (because they have transparent background), so the animation starts with some of them loading during the animation, looking pretty bad.

So, to fix it, I must add this line <link rel="preload" as="image" href="url-of-the-image.png"/> to the <head>.

To achieve it, I’m using Snippets plugin. If I’m not mistaken, the snippet should like this:

add_action( 'wp_head', function () { ?>

function my_custom_js() {