@hal.littel
To defer JavaScript files in theme.liquid in Shopify, follow these steps:
- Open your Shopify admin dashboard and go to Online Store > Themes.
- Click on the Actions dropdown menu and select Edit code.
- In the Layout section, locate the theme.liquid file.
- Find the tag in the theme.liquid file.
- Add the defer attribute to the script tag that includes the JavaScript file you want to defer. For example, if you want to defer a script called script.js, the code would look like this:
1
|
<script src="{{ 'script.js' | asset_url }}" defer></script>
|
- Save your changes and check your website to confirm that the JavaScript file is now deferred.
By adding the defer attribute to the script tag in the theme.liquid file, you are telling the browser to load the JavaScript file in the background and defer its execution until after the document has finished parsing. This can help improve the loading speed of your Shopify store.