How to Add Custom Javascript to Your Shopify Theme

Sell Online With Shopify
Trusted by millions of businesses worldwide
Sign up for a free trial and enjoy the first month of Shopify for $1.

Do you want to add a JavaScript in your Shopify pages? Sometimes you may need to add a JavaScript code to the entire website or into specific pages. In this article, we will show you how to easily add JavaScript in Shopify pages.

  • From your Shopify admin, go to Online Store > Themes.
  • Find the theme you want to edit, and then click Actions > Edit code.
  • Under Assets, click on to Add a new asset
  • A dialog popup will appear. Switch to Create a blank file tab. You must to fill the name for new file (eg: hura-custom) and select .js.liquid.
  • Click Add asset. This is the custom JS file you’ll be editing to add your custom JS.
  • Under Layout, select theme.liquid.
  • Scroll down the page until you find the closing body tag (</body>).
  • Paste the below code just before the tag.
  • Click Save and you are done.

Now if you want to add any custom Javascript code to your Shopify page, just open the generated JS file (hura-custom.js.liquid) to edit.

Happy coding!

Looking for Shopify Experts?

Hura Apps can help you take your store to the next level

Our team of experienced designers and developers can help you create a beautiful, high-converting Shopify store that will drive sales and increase customer satisfaction. From custom design to app development and optimization, we have the skills and expertise to help you achieve your eCommerce goals.

Get in touch

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *