This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// url (required), options (optional) | |
fetch('/some/url', { | |
method: 'GET' | |
}).then(function(response) { | |
// success | |
}).catch(function(err) { | |
// something went wrong | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function successListener() { | |
var data = JSON.parse(this.responseText); | |
console.log(data); | |
} | |
function failureListener(err) { | |
console.log('Request failed', err); | |
} | |
var request = new XMLHttpRequest(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('notificationclick', function(event) { | |
console.log('On notification click: ', event.notification.tag); | |
// Android doesn't close the notification when you click on it | |
// See: http://crbug.com/463146 | |
event.notification.close(); | |
// This looks to see if the current is already open and | |
// focuses if it is | |
event.waitUntil( | |
clients.matchAll({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('push', function(event) { | |
debugger; | |
console.log('Received a push message', event); | |
var title = 'Notification'; | |
var body = 'There is newly updated content available on the site. Click to see more.'; | |
var icon = 'https://raw.githubusercontent.com/deanhume/typography/gh-pages/icons/typography.png'; | |
var tag = 'simple-push-demo-notification-tag'; | |
event.waitUntil( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Push Demo", | |
"short_name": "Push Demo", | |
"icons": [{ | |
"src": "https://raw.githubusercontent.com/deanhume/typography/gh-pages/icons/typography.png", | |
"sizes": "192x192", | |
"type": "image/png" | |
}], | |
"start_url": "/index.html", | |
"display": "standalone", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('serviceWorker' in navigator) { | |
navigator.serviceWorker.register('service-worker.js').then(function(registration) { | |
// Registration was successful | |
console.log('ServiceWorker registration successful with scope: ', registration.scope); | |
registration.pushManager.subscribe({userVisibleOnly: true}).then(function(subscription){ | |
isPushEnabled = true; | |
console.log("subscription.subscriptionId: ", subscription.subscriptionId); | |
console.log("subscription.endpoint: ", subscription.endpoint); | |
// TODO: Send the subscription subscription.endpoint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
module.exports = function (grunt) { | |
grunt.initConfig({ | |
zopfli: { | |
compress: { | |
files: { | |
'processed.js.gz': 'original.js' | |
} | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Grunt Critical | |
├─┬ [email protected] | |
│ ├─┬ [email protected] | |
│ │ └── [email protected] | |
│ ├─┬ [email protected]. | |
│ │ └── [email protected] | |
│ └── [email protected] | |
├─┬ [email protected] | |
│ └─┬ [email protected] | |
│ └── [email protected] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>title</title> | |
<script src="dom-animator.min.js"></script> | |
</head> | |
<body> | |
<script> | |
var domAnimator = new DomAnimator(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (grunt) { | |
grunt.initConfig({ | |
critical: { | |
test: { | |
options: { | |
base: './', | |
css: [ | |
'css/style.css' | |
], |