Host Snaglist on your own server
How-to
Serve snaglist.js from your own server, so your pages load nothing from anyone else and you choose when to
update.
Before you begin
- A web server that serves your site's files, such as nginx, Apache, Caddy, or your app's own static folder.
Steps
- Download the version you want into the folder your server serves. This command saves version 0.4.0:
curl -fsSL -o snaglist.js https://raw.githubusercontent.com/TheMightyTRex/snaglist/v0.4.0/snaglist.js
- Check it downloaded in full. The file ends with
})();:
tail -c 20 snaglist.js
- Serve it as JavaScript. Most servers do this already for
.jsfiles. - Let browsers keep it for a while. For nginx, this rule keeps it for a day:
location = /snaglist.js { add_header Cache-Control "public, max-age=86400"; }
- Add the script tag to your pages: Add Snaglist to a website.
- If your site sends a Content Security Policy, Snaglist works under a strict one such as
default-src 'self'. It needs no other site, no inline script and no inline styles.
Things to note
- You can load it from a content delivery network instead, pinned to a version, but that site then receives your visitors' requests:
<script src="https://cdn.jsdelivr.net/gh/TheMightyTRex/snaglist@v0.4.0/snaglist.js" defer></script>
- To take reports on your own server too, read Send reports to your own server.