Get started with offline-js CDN
MIT licensed
Library: sync data with local database, serve cached content offline.
Tags:- offline
- online
- internet
- network
- ajax
- notification
- javascript
- client-side
Stable version
Copied!
How to start using offline-js CDN
// Initialize OfflineJS
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('my-site-cache').then(function(cache) {
return cache.addAll([
'index.html',
'style.css',
'script.js', // Add your HTML, CSS, and JavaScript files here
'https://cdn.example.com/image.jpg' // Add images or other external files here
]);
})
);
});
// Serve cached content when offline
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!