Trapezoid
Trapezoid is a simple web framework for service workers. It features:
- define precached items
- intercept GET fetches and pass custom responses
- create custom responses for when offline only
Install
install locally using npm and refer locally from your service worker
npm install trapezoid
;
or reference CDN file on rawgit in your service worker:
;
Hello World
app.js
if 'serviceWorker' in navigator window;
sw.js
// Get things startedvar app = ; // Create a custom GET handlerapp // Declare something to precacheapp; // Or declare many things to precacheapp; // Create a fallback handler for when offline onlyapp // Give it a unique name for cacheingapp;