Type: There are 4 resource types supported
Combined Resource - This allows you to combine multiple files and output them as a single file.
Local File - Points to a file store locally on the Miva server
External File - References a path to a JS file hosted externally, typically from a CDN
Inline Script - Outputs an inline Script Tag
File Path: The relative path to the file (local file) or the absolute path to the external file. N/A for inline script tags
Script Tag Attributes: Preview of the script output including custom tag attributes you have added. These can be added or removed by selecting the resource from the batch list and clicking the “Edit Attributes” button.
Global: Whether the script appears on all pages. Default is global. If a script is not global, you have the ability to select which pages you would like it to appear on by selecting the resource from the batch list and clicking on the “Pages” button.
Here you can assign a JS resource to be output on a specific page vs all pages (global)
Local Files - For files that live locally on your Miva Server, when editing, Miva will open the file and allow you to make changes and resave the file on the server to the same location. It's important to note that if you are editing files via the admin and via FTP at the same time, it's possible to overwrite your changes. Its up to you, the developer, to ensure the JS files are not being overwritten by someone else. With local files, there is also no version control or access to Miva variables or template language.
Inline Script - Inline scripts allow for admin editing as well as automatic version history and Miva variables and template language. Because these inline scripts get compiled just like any other page template you can use the power of the Miva Template Language to set variables. The scope of what variables are available will depend on what page the JS Resource is being output on. For example if you wanted to create a JS resource for Adwords Conversion tracking and pass in the order total, as long as you are outputting the script on the INVC page, those variables will be automatically available.
External Files - Editing Is not available for external files
All three JS Resource Types (local, inline, external) support adding custom Attributes to the Script Tag Output. To add your own attributes to the script tag, select the resource and click “Edit Attributes” button. Here you can add custom name/value pairs which will be output in the script tag on the page.
Page Source Output:
These data attributes are: data-script-group and data-script-code
These will always appear after the src attribute and are not editable via the admin (they cannot be removed)
When uploading local files, Miva will always upload all files to a new folder in the following path:
Where /mm5/ is your base directory and 00000001 is your store number. These two values could change based on your specific install of Miva.
This path cannot be changed for files uploaded via the admin, however you can manually FTP files to any path on the server and then manually set that path when adding the file:
Once you have your combined resource, you can assign it to output any resource group so it outputs on the page.
The combined JS file will get output using clientside.mvc and will look like this:
If using the SRI attribute you'll want make sure you re-generate it after any changes or else the file will fail to load.
There is now a new button for "Generate SRI" whcih allows you to generate an SRI for any file using SHA256, SHA385, SHA512 or All. You can also clear the SRI as well.
One nice feature of the Asset Management Tool is you can specify tracking scripts to only be output on certain pages. This is useful for example when adding Conversion Tracking scripts where you only want the JS output on a specific page.
To do this add the script and set the Global flag to off/false. Then select the script from the list and you’ll see a “Pages” Button
This will bring up a page to select which pages the script gets output on:
By default there is a single resource group called head_tag. This tag is included on every front end page and allows you to add your own custom JS files to be output when it runs.
Lastly, you would need to add the resource group tag to the global footer (or wherever you want it to show up)
This code will include the JS Resource into the page regardless of whether it is marked as Global or assigned to the specific page. However the JS Resource must be active to be included in the page.