Inline JavaScript

Is there any known way to convert the blocks of inline JavaScript used in the Shopify rendered page so that they’re included instead as external src files?

Thanks,
Todd

Hi @Todd_White

That’s an interesting question. Which JS are you referring to specifically?

Why do you want to move it to it’s own external script?

Analysis tools assess inline as a non-best practice and can produce a diminished rating assessment of a website if many different blocks of inline JavaScript are found.

If you want the javascript code to be inside the DOM tree itself, you’d need to directly write it in the liquid file.

If you want to load it from a URL (more recommended, ideally from a CDN), simply create a tag directed to that src, and just make sure to make it async or defer, this way it won’t affect performance considerably.