If SmartVideo has been on your site for a while, the snippet in your <head> may load a script called swarmdetect.js. That is our older loader. The tag our install guides show today loads the player script, swarmcdn.js, directly. This article shows how to tell which one you have and how to swap it. If your videos play normally today, the swap is routine upkeep rather than a repair.
This doesn’t apply to WordPress plugin sites. The SmartVideo plugin adds the snippet for you, so there is nothing to change by hand.
How to tell which tag you have
Open your site, view the page source (Ctrl-U, or Command-Option-U on a Mac), and search for swarmcdn.com. You have the older loader if a script URL contains swarmdetect.js, like this:
<script src="https://assets.swarmcdn.com/cross/swarmdetect.js"></script>
A ?ver= suffix on that URL (swarmdetect.js?ver=…) usually means the WordPress plugin added the tag. Update the plugin instead of editing the tag by hand: a ?ver= request is served the pre-rebuild bundle, which writes its own tags with document.write, so it must not be loaded async.
You already have the current tag if you see this instead:
<script async data-cfasync="false" src="https://assets.swarmcdn.com/swarmcdn.js"></script>
You will usually see a swarmoptions block just above the loader. That block holds your settings. Leave it as it is.
Swap the loader line
Replace only the loader line. Keep your existing swarmoptions block above it exactly as it is:
<script data-cfasync="false">
var swarmoptions = {
swarmcdnkey: "YOUR_SWARM_CDN_KEY",
// ...your existing settings, unchanged...
};
</script>
<script async data-cfasync="false" src="https://assets.swarmcdn.com/swarmcdn.js"></script>
Keep data-cfasync="false" on both script tags. It tells Cloudflare’s Rocket Loader to leave them alone, which has broken playback on customer sites in the past.
If your site has a staging copy, update it too, so production and staging load the same tag.
Where the snippet lives depends on your platform. The platform steps are in Using SmartVideo with Shopify, Squarespace, Wix, and other platforms and in the installation guide for your platform.
What the older loader does
swarmdetect.js is a small script whose job is to add the player script, swarmcdn.js, to your page. If the browser is still reading your page when the tag runs and the tag isn’t marked async, it writes the player’s script tag into the page with document.write. Otherwise it inserts the script element itself. Either way the player is fetched in a second step, after swarmdetect.js has loaded.
If your site sets swarmvcustomvideo, or you have custom scripts that expect the player to load synchronously, contact support before swapping. For swarmvcustomvideo sites the older loader always uses document.write, and it loads a custom version of the player script and stylesheet instead of the standard ones.
The current tag is marked async and points straight at swarmcdn.js, so there is no intermediate script. It is also the tag every current install guide uses, which makes it the one our support instructions assume.
After the swap
- Hard-reload a page with a video on it (Ctrl-Shift-R, or Command-Shift-R on a Mac) and confirm the video plays.
- If you use SmartVideo on background or hero videos, check a page with one. See How to accelerate background videos with SmartVideo.
- Open your browser console (F12, then the Console tab) and look for messages mentioning SmartVideo. If you see one you’re not sure about, send it to us and we’ll read it for you.
If something doesn’t come back, the video not playing troubleshooting guide covers the usual causes, and you can put the old tag back while you sort it out.
Refresh your settings at the same time
The Player page in your dashboard generates a swarmoptions block from a set of toggles. Compare it against your current block rather than replacing the block wholesale: a block that has been in place for years may contain options you still want. Every option and what it does is in Configure SmartVideo with swarmoptions.
Don’t have an account yet?
Create one at swarmify.com/pricing/, then follow Get started with Swarmify’s SmartVideo. New installs start with the current tag, so none of this applies to you.
Not sure which tag your site uses? Email support@swarmify.com with the page URL and we’ll check it for you.
Keywords: swarmdetect.js, swarmcdn.js, update script tag, old snippet, legacy loader, document.write, async script, new install snippet, data-cfasync, swarmoptions, which script tag do I have