3

I've tested my website with Pingdom and suggested to combine external javascripts, but I don't know how to do this with shopify website.

2
  • Did you do some investigation before asking this question? Commented Sep 7, 2017 at 3:53
  • yes, i also minified the js but still my score in pingdow wont get higher than 83 Commented Sep 11, 2017 at 6:12

1 Answer 1

3

Adding external script files for Shopify theme is pretty simple.

You just need to upload your script file to the asset folder of your theme file. Or you can create a .js file to paste your code there. After that you just need to include that script file to the theme.liquid file.

Just need to add the following before end of tag in the theme.liquid file.

{{ 'your-script-file-name.js' | asset_url | script_tag }}

Sign up to request clarification or add additional context in comments.

5 Comments

i tried to do it,but it only displays a broken site
some of the js files are not inside assets
asset_url filter will search for the file in the asset folder of your theme
If the file is in the themes folder, then it's not "external" as the OP title asks for.
You can either download the script and upload it to the Shopify theme CDN to use or simply through the Script tag which can include the external JS file or link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.