JavaScript Libraries

Keeping your JavaScript libraries current

Most modern templates, as well as the Zen Cart admin, bundle in the JavaScript library jQuery, as well as other JavaScript libraries.

You must check the versions of any libraries you are importing to ensure that you are running the latest, and not an older version with known vulnerabilities.

Your template’s html_header.php or jscript/jscript_xxxxxxx.* files are common places to check for direct references to old libraries. You will also want to check the includes/templates/YOURTEMPLATE/jscript folder to see if there are old versions stored there.

Remember that addons to templates often bring in their own jQuery version that is likely older than the one you want to use for your template. Make sure you’re only loading one copy of jQuery, and that the copy you are loading is current and compatible with all the other javascript and/or jQuery features you’re already using.

A very easy way to test whether your libraries are current is to use Google Lighthouse utility. In Google Chrome, right click and select “Inspect.”

Inspect

Then in the dialog that comes up, on the right side, click “Lighthouse.”

Lighthouse

Click the Generate Report button, and look under “Best Practices.” The second error message in this screenshot indicates some libraries need updating.

Lighthouse error




Still have questions? No problem! Just head over to the Zen Cart support forum and ask there in the appropriate subforum. In your post, please include your Zen Cart and PHP versions, and a link to your site.

Is there an error or omission on this page? Please post to General Questions on the support forum. Or, if you'd like to open a pull request, just review the guidelines and get started. You can even PR right here.
Last modified October 18, 2020 by Scott C Wilson (707fb1c).