📦 CDN Usage (One Line)
Add this single line to any HTML page:
<script src="https://cdn.jsdelivr.net/gh/xsukax/xsukax-PWA-Transformer@main/pwa.js" data-auto-init data-app-name="My App" data-theme-color="#4a90e2"></script>
That's it! Your site is now a PWA with offline support and installation capability.
🎯 Available CDN Options
jsDelivr (Recommended - Fast & Reliable):
https://cdn.jsdelivr.net/gh/xsukax/xsukax-PWA-Transformer@main/pwa.js
GitHub Raw:
https://raw.githubusercontent.com/xsukax/xsukax-PWA-Transformer/main/pwa.js
Statically:
https://cdn.statically.io/gh/xsukax/xsukax-PWA-Transformer/main/pwa.js
⚙️ Configuration Options
Minimal (App name and theme only):
<script src="https://cdn.jsdelivr.net/gh/xsukax/xsukax-PWA-Transformer@main/pwa.js" data-auto-init data-app-name="My Localhost" data-theme-color="#2c3e50"></script>
Full configuration:
<script src="https://cdn.jsdelivr.net/gh/xsukax/xsukax-PWA-Transformer@main/pwa.js" data-auto-init data-app-name="My Localhost" data-app-short-name="Localhost" data-theme-color="#2c3e50" data-background-color="#ffffff"></script>
🎨 Manual Initialization
For advanced configuration, use manual initialization:
<script src="https://cdn.jsdelivr.net/gh/xsukax/xsukax-PWA-Transformer@main/pwa.js"></script>
<script>PWA.init({appName:'My App',themeColor:'#4a90e2',cacheStrategy:'cacheFirst'});</script>
📱 Installation Handling
Add an install button to your page:
<button id="installBtn" onclick="PWA.install()">Install App</button>
<script>window.addEventListener('pwa-install-available',()=>{document.getElementById('installBtn').style.display='block';});</script>
🔧 Service Worker
The library automatically tries to load sw.js from:
- Local file:
./sw.js (if exists in your root)
- CDN fallback:
https://cdn.jsdelivr.net/gh/xsukax/xsukax-PWA-Transformer@main/sw.js
- Auto-generate: Call
PWA.downloadServiceWorker() to download
No manual setup required! The library handles everything automatically.
✅ Current Status
Initializing PWA...
🌟 Features
- ✅ One-line integration - Just add a script tag
- ✅ CDN hosted - No downloads, no setup
- ✅ Offline support - Works without internet
- ✅ Installable - Add to home screen on all platforms
- ✅ Cross-platform - Windows, macOS, Linux, Android, iOS
- ✅ Zero dependencies - No external libraries required
- ✅ Auto SW fallback - CDN or local service worker
- ✅ Privacy-first - No tracking, no analytics
📚 API Reference
Initialization:
PWA.init({appName:'My App',themeColor:'#4a90e2'})
Installation:
PWA.install() - Trigger install prompt
PWA.canInstall() - Check if installable
PWA.isStandalone() - Check if installed
Service Worker:
PWA.downloadServiceWorker() - Download sw.js
PWA.clearCache() - Clear all caches
PWA.unregister() - Unregister service worker
Info:
PWA.getInfo() - Get all PWA information
PWA.isOnline() - Check network status