Skip to content

Instantly share code, notes, and snippets.

View anurag-majumdar's full-sized avatar
💭
Creativity is the art of application of learning.

Anurag Majumdar anurag-majumdar

💭
Creativity is the art of application of learning.
View GitHub Profile
var staticAssetsCacheName = 'todo-assets-v3';
var dynamicCacheName = 'todo-dynamic-v3';
self.addEventListener('install', function (event) {
self.skipWaiting();
event.waitUntil(
caches.open(staticAssetsCacheName).then(function (cache) {
cache.addAll([
'/',
"chunks/todo.d41d8cd98f00b204e980.js","index.html","main.d41d8cd98f00b204e980.js"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<!-- Critical Styles -->
<style>
html {
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
// Define the storage type (local or session)
var Storage = function (type) {
// Define the storage type (local or session)
function setData(data) {
// Sets the data into storage
}
function clearData() {
// clears data from storage
}
if (!String.prototype.startsWith) {
String.prototype.startsWith = function (searchString, position) {
position = position || 0;
return this.substr(position, searchString.length) === searchString;
};
}
const staticCacheName = 'app-shell-static-v1';
const staticCacheFileNames = [
'public/offline.html',
'lib/app.js'
];
self.addEventListener('install', (event) => {
self.skipWaiting();
event.waitUntil(
(function () {
class App {
constructor() {
this.registerServiceWorker();
this._app = document.querySelector('.app');
this.fetchOfflineContent = this.fetchOfflineContent.bind(this);
this.fetchAppContent = this.fetchAppContent.bind(this);
self.addEventListener('online', this.fetchAppContent);
self.addEventListener('offline', this.fetchOfflineContent);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> App Shell </title>
<style>
/* Critical Inline Styles */
// ES6 style
class Gorilla extends Animal {
constructor(name, weight) {
super(name, weight);
}
showVigour() {
return `${super.eat()} ${this.poundChest()}`;
}
@anurag-majumdar
anurag-majumdar / extends.js
Created April 16, 2018 13:41
Comparison between ES6 and traditional approach to extending classes
// ES6 style
class Gorilla extends Animal {
constructor(name, weight) {
super(name, weight);
}
//...
}
// Traditional style
function Gorilla(name, weight) {
// ES6 style
class Animal {
// ...
eat() {
return `${this.name} is eating!`;
}
sleep() {
return `${this.name} is going to sleep!`;
}