Overview
Gwtar is a new archive format that packs large numbers of assets into a single HTML file while still allowing efficient lazy loading in browsers. The file contains both JavaScript and embedded tar data that work together to load assets on-demand.
The Breakdown
- Uses window.stop() to halt browser downloading after JavaScript loads, preventing the entire large file from being downloaded upfront
- Embeds uncompressed tar archive data directly in the HTML file after the JavaScript, creating a self-contained package with all assets
- Rewrites asset URLs to localhost so they fail, then uses a PerformanceObserver to catch failed requests and serve content from the embedded tar data instead
- Makes HTTP range requests to fetch specific parts of the tar archive only when assets are actually needed by the page
- Cannot run locally due to browser security restrictions - requires either a web server or manual tar extraction to use