A benchmark comparing the performance of zip-go and yauzl ZIP libraries for Node.js and browsers.
- π Node.js benchmarks - Traditional file-based testing
- π Browser benchmarks - Compare performance in browsers using esm.sh
- π Multiple test scenarios (metadata, memory, disk, specific file)
- πΎ Memory usage tracking
- π― Fair comparison with memory-based testing
npm installThe browser benchmarks require bundled JavaScript files. Build them with:
npm run buildThis creates bundled files in the dist/ directory that include zip-go, yauzl, and all necessary Node.js polyfills for browser compatibility.
The bundled files are committed to the repository, so you only need to rebuild if you update dependencies or modify the build configuration.
Run the benchmark with a ZIP file:
node benchmark.js <path-to-zip> [specific-file-name]Basic benchmark:
node benchmark.js ./test.zipInclude specific file test:
node benchmark.js ./test.zip README.mdRun with garbage collection exposed (for better memory measurements):
node --expose-gc benchmark.js ./test.zipQuick test with included test.zip:
npm run bench:nodeThe browser benchmarks allow you to test ZIP library performance directly in your browser.
- Full Benchmark (
browser-benchmark.html) - Compares zip-go and yauzl using esm.sh - Demo (
browser-demo.html) - Simple ZIP analyzer without external dependencies
-
Generate a test ZIP file (optional, if you don't have one):
npm run create-test-zip
-
Start the local server:
npm run serve
-
Open your browser:
-
Select a ZIP file and click the appropriate button
- π¦ yauzl bundled - Uses
fromBuffer()method with bundled Node.js polyfills for browser compatibility - π zip-go native - Works directly with browser File/Blob objects
- π§ͺ Fair comparison - Both libraries read from memory (File object vs ArrayBuffer)
- π¬ Browser-specific tests - Tests optimized for browser environments
- π― Demo version - Pure browser implementation with no external dependencies
- ποΈ No external CDNs - All dependencies are bundled locally for reliability
yauzldepends on Node.js built-ins, which are bundled as polyfills for browser compatibilityyauzlusesfromBuffer()method to work with ArrayBuffer in browserszip-goworks natively with browser Blob/File objects- Both read from memory for fair comparison (not from virtual filesystem)
- Libraries are bundled using esbuild - no external CDN dependencies
- The demo version (
browser-demo.html) is a lightweight alternative that analyzes ZIP structure without external libraries
π‘ Side Note: This benchmark demonstrates what happens when you try to browserify packages built with Node.js dependencies. yauzl requires 51 npm packages and extensive polyfills (buffer, streams, zlib, etc.), resulting in a 4608% larger minified bundle. For better cross-platform compatibility, avoid using Buffer and Node.js streams in libraries intended for browser use. Build with browser-native APIs (Blob, File, ReadableStream) from the start.
The benchmark runs four different tests:
Tests the speed of reading metadata for all entries in the ZIP file without extracting data.
Tests the performance of reading all files into memory as ArrayBuffers.
Tests the real-world scenario of streaming all files to disk. This is the most realistic performance test.
Tests random access performance by finding and reading a specific file from the archive.
Each test displays:
- Execution time in milliseconds
- Number of entries/files processed
- Heap memory usage
- Winner of each test
Example output:
π Performance Test: yauzl vs zip-go
=====================================
Test file: test.zip
π Test 1: Read central directory
zip-go: 2.66ms, 5 entries, heap: 4.68MB
yauzl: 5.38ms, 5 entries, heap: 4.53MB
Winner: zip-go π
πΎ Test 2: Read all files to memory
zip-go: 2.22ms, 4 files, heap: 3.97MB
yauzl: 4.11ms, 4 files, heap: 4.06MB
Winner: zip-go π
πΏ Test 3: Stream all files to disk
zip-go: 13.12ms, 4 files, heap: 5.07MB
yauzl: 5.02ms, 4 files, heap: 5.25MB
Winner: yauzl π
π― Test 4: Find and read a specific file
zip-go: 0.76ms, found: true
yauzl: 1.07ms, found: true
Winner: zip-go π
β
All tests complete!
Only reason why yauzl won the stream to disc was b/c nodejs dose not have good alternative way to write blob or web stream to disc using web standards: nodejs/node#61684
- Node.js >= 18.0.0
MIT