diff --git a/_includes/scripts.html b/_includes/scripts.html index 058ba1b337..fca6998800 100644 --- a/_includes/scripts.html +++ b/_includes/scripts.html @@ -16,6 +16,7 @@ + {% endif %} diff --git a/assets/js/src/pwa.js b/assets/js/src/pwa.js new file mode 100644 index 0000000000..95ee339482 --- /dev/null +++ b/assets/js/src/pwa.js @@ -0,0 +1,15 @@ +/* eslint no-console:off */ + +(function setupSW() { + 'use strict' + + if ('serviceWorker' in navigator) { + window.addEventListener('load', function () { + navigator.serviceWorker.register('/sw.js').then(function (registration) { + console.log('ServiceWorker registration successful with scope: ', registration.scope) + }).catch(function (err) { + console.log('ServiceWorker registration failed: ', err) + }) + }) + } +}()) diff --git a/package.json b/package.json index 0f0618284a..a88d0498b1 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "js-compile-bundle": "shx cat js/src/util.js js/src/alert.js js/src/button.js js/src/carousel.js js/src/collapse.js js/src/dropdown.js js/src/modal.js js/src/scrollspy.js js/src/tab.js js/src/tooltip.js js/src/popover.js | shx sed \"s/^(import|export).*//\" | babel --filename js/src/bootstrap.js | node build/stamp.js > dist/js/bootstrap.js", "js-compile-plugins": "babel js/src/ --out-dir js/dist/ --source-maps", "js-minify": "uglifyjs --config-file build/uglifyjs.config.json --output dist/js/bootstrap.min.js dist/js/bootstrap.js", - "js-minify-docs": "uglifyjs --config-file build/uglifyjs.config.json --output assets/js/docs.min.js assets/js/vendor/anchor.min.js assets/js/vendor/clipboard.min.js assets/js/vendor/holder.min.js assets/js/src/application.js", + "js-minify-docs": "uglifyjs --config-file build/uglifyjs.config.json --output assets/js/docs.min.js assets/js/vendor/anchor.min.js assets/js/vendor/clipboard.min.js assets/js/vendor/holder.min.js assets/js/src/application.js assets/js/src/pwa.js", "js-test": "phantomjs ./node_modules/qunit-phantomjs-runner/runner.js js/tests/index.html 60", "js-test-cloud": "ruby -r webrick -e \"s = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd, :Logger => WEBrick::Log.new('/dev/null'), :AccessLog => []); trap('INT') { s.shutdown }; s.start\" & grunt saucelabs-qunit", "docs": "npm-run-all docs-compile docs-lint", diff --git a/sw.js b/sw.js new file mode 100644 index 0000000000..44d1d2774a --- /dev/null +++ b/sw.js @@ -0,0 +1 @@ +// empty for now