There's now a second way to install the Syncle widget. It has the same functionality as the standard installation, but it loads a fixed version of the widget and lets the browser verify that the file hasn't changed.
đĄ The standard installation still works and remains our recommended method for most sites. Use this option if your security policy requires third-party scripts to be pinned and verified.
The browser checks the widget before running it
This method uses Subresource Integrity (SRI). The installation code includes a version number and an integrity hash that belongs to that exact version.
When the page loads, the browser compares the widget file against the hash. If the file has changed in any way, the browser refuses to run it and logs an error in the console. So if the widget source were ever compromised, your site wouldn't be affected. The widget simply wouldn't load.
Updates don't happen automatically
Because the version is fixed, your site won't receive widget updates or bug fixes on its own. To move to a newer version, you update the installation code yourself. The steps are below.
Settings changes we make for your account still apply as normal. Your configuration loads separately from the widget code, so it isn't affected by the pinned version.
Installation code
Add this code to your site in place of the standard installation code. You can add it the same way as the standard code: directly in your page template, or with a tag manager such as Google Tag Manager.
<script>
(function(d, e, n){
e = d.createElement('script');
e.async = true;
e.src = 'https://api.videoly.co/widget/6.29.1/syncle.js';
e.integrity = 'sha384-z9DuEhHwQlsBxRjvsyeNlIfHj0oOABTh+q9exD9AqKW2QpUTfpSbzsdhVjrnEG2O';
e.crossOrigin = 'anonymous';
e.dataset.shopId = '{SHOP_ID}';
n = d.getElementsByTagName('script')[0];
n.parentNode.insertBefore(e, n);
})(document);
</script>
Replace {SHOP_ID} with your shop ID. Not sure what it is? Contact us at [email protected].
Keep the version (6.29.1) and the integrity value together. They must match, because the hash belongs to that specific version.
Don't remove the crossOrigin line. The browser needs it to run the integrity check.
Upgrading to a new version
All supported versions and their integrity hashes are listed at api.videoly.co/widget/releases. Each major update or bug fix is added there as a new version, so it's worth checking the list now and then.
Open the releases page and find the version you want to move to.
Copy its version number and its matching integrity hash.
In your installation code, replace the version number in the src URL and the value of integrity.
Publish the change, then open a product page and check that the widget loads with no integrity errors in the browser console.
đĄ Want to be extra careful? Try the new version in your testing environment first.
If the widget doesn't load
Open your browser's developer console on a product page. If the version and the integrity hash don't match, you'll see an error like this one from Chrome:
Failed to find a valid digest in the 'integrity' attribute for resource 'https://api.videoly.co/widget/6.29.1/syncle.js' with computed SHA-384 integrity '...'. The resource has been blocked.
Check that the version number and the integrity value in your code both come from the same version on the releases page, copied exactly. Still stuck? Contact us at [email protected].
Smaller widget file
As part of this work, the widget file is now 10â20% smaller, depending on which extensions your site uses. This applies to both installation methods.
