Preload a script

New Member
1 0 0

Hi, 

 

I would like to preload cart.js on my front page . 

I don't have knowledge on css...I put this code on theme.liquid and it is not working.

If you can help me, thank you in advance. 

 

<head>

<link rel="preload" href="cart.js" as="script" crossorigin="anonymous">

</head>

<body>

<script crossorigin='anonymous' src="cart.js"></script>
</body>

0 Likes
New Member
10 0 0

Im the same here.. looking for answer - to preload script... as per recommend by google. - https://web.dev/defer-non-critical-css/

 

So far tried this... didnt go well..

<link title="theme" rel="preload" href="{{ 'theme.scss.css' | asset_url | stylesheet_tag }}" as="style">
<noscript><link rel="stylesheet" href="{{ 'theme.scss.css' | asset_url | stylesheet_tag }}"></noscript>

0 Likes