Skip to content

Allow placing main script file in a separate directory (CDN support)

Compare
Choose a tag to compare
@TalAter TalAter released this 30 Dec 12:30
· 139 commits to master since this release

You can now load the main UpUp script (upup.min.js) from a completely different directory, or even server, than where you keep the ServiceWorker file (upup.sw.min.js).

This is a great way to load upup.min.js from a CDN, and then only for users who use the Service Worker, load upup.sw.min.js from your domain's root directory.

💡 upup.sw.min.js must remain under the main domain (preferably at the root level), because that defines its scope. Read more here.

<script src="//cdnjs.cloudflare.com/ajax/libs/UpUp/0.2.0/upup.min.js"></script>
<script>
UpUp.start({
  'content-url': 'offline.html',
  'assets': ['/img/logo.png', '/css/style.css', 'headlines.json'],
  'service-worker-url': '/upup.sw.min.js'
});
</script>
Contributed by: @mdibaiee