Building a World Map with only 500 bytes
Summary
Iwo Kadziela, with assistance from Codex, devised a novel method to generate a credible ASCII world map using an exceptionally small footprint of just 445 bytes of data. This technique primarily relies on deflate compression, which is seamlessly integrated through a compact JavaScript snippet. The implementation cleverly employs `fetch()` with `data:` URIs to retrieve the compressed data, subsequently piping it through a `DecompressionStream('deflate-raw')`. This process efficiently decompresses the data, allowing it to be rendered as an ASCII map. The approach showcases an ingenious application of web APIs for highly efficient data representation and display, yielding a visually effective world map from minimal data.
Key takeaway
For web developers focused on optimizing asset delivery or creating highly compact visualizations, you should explore using deflate compression with `data:` URIs and `DecompressionStream`. This technique allows for embedding significant content, like a detailed ASCII map, using only hundreds of bytes, drastically reducing network payload and improving initial page load performance. Consider this approach for small, static assets or dynamic content that benefits from extreme size reduction.
Key insights
Deflate compression combined with `fetch()` and `DecompressionStream` enables highly compact ASCII map generation.
Principles
- Data compression minimizes payload size.
- Browser APIs can decompress data streams.
Method
Compress map data using deflate. Embed compressed data in a `data:` URI. Fetch URI, pipe through `DecompressionStream('deflate-raw')`, then render the resulting text as ASCII.
In practice
- Embed small assets via `data:` URIs.
- Use `DecompressionStream` for client-side decompression.
- Generate compact visual representations.
Topics
- Deflate Compression
- JavaScript
- Web APIs
- Data URIs
- ASCII Art
- Frontend Optimization
Best for: Software Engineer, Creative Technologist
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Simon Willison's Weblog.