Storefront Scripts
An app can add features to the storefront with one JavaScript file per version. Storeep reviews the file, hosts it on its own CDN and loads it on every page of the stores that install your app.
How It Works
- Upload one JavaScript file under Storefront script on the Version tab of your app, in Settings, then App development, and click Save.
- Storeep reviews the version. Once it is approved, every store with your app installed loads the file after the page has finished loading.
- The file is served from
cdn.storeep.com, at an address that never changes and is cached for a year. The tag carries anintegrityhash, so the browser refuses any file that differs from the one Storeep holds. - To change the script, upload the new file in a new version. It gets a new address, and the stores switch to it once that version is approved.
fetch(), for example https://example.com/storeep/widget.MutationObserver.Which Script a Store Loads
| Store | Loads |
|---|---|
| A development store, one you own | The script of your newest version that is not retired, a draft included, so you can test it before review. |
| Every other store | The script of your approved version only. |
Limits
| Rule | Limit |
|---|---|
| Files per version | 1 JavaScript file, UTF-8 text. |
| File size | 50 KB (51,200 bytes), minified. |
| Script type | A classic script, not a module, run with async after the page load event. |
| Settings per store | 16 KB of JSON, one object. |
| Address | One address per saved file, cached for a year. |
Reading Your Settings
The settings your app saves for a store through the app settings endpoint reach your script in a JSON block printed on every page. Its id is st-app- followed by your app id, so your script finds it with document.getElementById(). Your app id is on the Credentials tab of your app.
The block is plain JSON, never run as code. A store whose settings you have not saved yet gets an empty object.
<script type="application/json" id="st-app-123456789012345678">{"color":"#1a73e8","position":"bottom"}</script>// runs once on every visit, its names stay out of the page's own scripts
(function ()
{
// your app id, shown on the Credentials tab of your app
const appId = '123456789012345678';
// the block storeep prints for your app on every page
const settingsBlock = document.getElementById(`st-app-${appId}`);
// no block means there is nothing to set up on this page
if (!settingsBlock) return;
// the object your app saved for this store
const settings = JSON.parse(settingsBlock.textContent);
// builds the widget with the store's own settings
console.log(settings.color, settings.position);
})();Testing Your Script
- Install your app on a development store, save your draft with its script, and open the storefront.
- Storeep does not report a storefront script that fails. Test it on your own store before you submit.
- A script that throws an error, or that the browser refuses, does nothing, and neither you nor the merchant is told. So test with the browser's console open, on a phone and on a computer.
- Catch your own errors and send them to your server if you want to hear about them.
When the Script Does Not Load
- The merchant turned off Storefront script in your app's window. The app stays installed and keeps its API access. The switch is saved before your app is asked about the rest of the form, so a merchant can always turn the script off.
- The merchant uninstalled your app.
- Storeep suspended your app.
- The version the store runs has no script.
- The page is the one a blocked visitor sees.
A change reaches the storefront within seconds: Storeep drops the store's cached page settings each time one of these happens and each time a new version is approved.
Review Rules
Every version is reviewed before it reaches a merchant's store. A script that breaks one of these rules is rejected, with a note saying what to change:
- The script does what your listing says, and nothing else.
- It never loads more code: no other
<script>tags, noeval(), nonew Function(), no code downloaded withfetch(). - It is readable. Minified code is fine, obfuscated code is rejected.
- It never moves the page: space for a widget is reserved before it appears, and nothing is inserted above content the visitor is already looking at.
- It never blocks the page. Long work is split up or left for
requestIdleCallback(), and scroll and touch listeners are passive. - It never reads or changes the checkout form, prices or the cart total.
- It never sends a visitor's personal data anywhere your privacy policy does not name.
- Its own CSS classes and global names start with a prefix of your app, and it never depends on Storeep's own classes, which can change at any time.
Review and Publishing covers the rest of the review.