Javascript
The exact structure of your theme's javascript file(s) will depend on who developed it. Not all theme developers use the same structure. Older versions of our template themes will use a different structure and including an application.js and plugins.js file, whereas newer versions may only contain an application.js file or scripts.js.
JavaScript is used to add interactivity to your website. Your theme will include at least one JavaScript file, typically used to control features such as an image zoom or slideshow.
JavaScript also adds interactivity to your product pages by enabling special features with variations such as switching the product image when a particular variation is selected.
jQuery
jQuery is a popular JavaScript library which is included in your theme by default. You can write jQuery code in any of your theme's JavaScript files.
Creating a new javascript file
Rather than editing an existing JavaScript file, it might be better for you to create new scripts within a new Javascript file.
To create a new file make sure that you are in advanced mode on the theme editor by clicking the 'advanced mode' toggle at the top of the file list on the left hand side.
Click the 'create new' link in the 'assets/js' folder and give the new file a name. We'd recommend using something like extra.js
A reference to the JS file now needs to be placed within master.twig so navigate to the 'views/templates' folder and click to open this file.
At the bottom of the file, insert the reference to the new JS file (as shown on the example below).
<script src="{{ asset_url('js/extra.js') }}"></script>
Minification
Javascript files are automatically compressed unless the file extension is .min.js..
Comments are automatically removed unless @license or @preserve are used.