node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



ZipLoader is a light weight zip file loader and unzipper for Web browsers. (only 25KB (gzipped 9KB) )

Plus, It makes easy to make loading progress bar.

Latest NPM release MIT License dependencies Status devDependencies Status

Demos can be seen here.


Both standalone version and NPM module version are available.


Copy ZipLoader.js from /dist/ZipLoader.js and place it in your project.

<script src="./js/ZipLoader.js"></script>


$ npm install --save zip-loader


import ZipLoader from 'zip-loader';

To load and unzip

Make a loader instance with a target zip url. Then, load() it.

var loader = new ZipLoader( './' );

You can get loading progress in 'progress' event while loading.

When it's done, the zip file is automatically unzipped and 'load' event will be triggered.

As the result, you will get files property under the instance, that consists of filename and binary buffer.

var loader = new ZipLoader( './' );
loader.on( 'progress', function ( e ) {
  console.log( 'loading', e.loaded, );
} );
loader.on( 'load', function ( e ) {
  console.log( 'loaded!' );
  console.log( loader.files );
  var json = loader.extractAsJSON( 'foldername/data.json' );
  console.log( json );
} );

Pick up unzipped files

There are 3 (+1) ways to pick up unzipped files.

  • as a text.
  • as a JSON.
  • as an URL (for <img>, <audio>, <video> etc).

The 1st augment is key of loader.files object, that represents "path + filename" in zipped folder.

As a text

var string = loader.extractAsText( 'foldername/text.txt' );


var json = loader.extractAsJSON( 'foldername/data.json' );

As an URL

The 2nd arguments is its MIMEType.

var url = loader.extractAsBlobUrl( 'foldername/pict.jpg', 'image/jpeg' );

with three.js

ZipLoader can provide altanative JSONLoader for zipped JSON.

// At first, prepare to use THREE.js in ZipLoader
ZipLoader.install( { THREE: THREE } );
var loader = new ZipLoader( './' );
loader.on( 'load', function ( e ) {
  var result = loader.loadThreeJSON( 'assets/threejs-model.json' );
  var mesh = new THREE.Mesh(
    new THREE.MultiMaterial( result.materials )
  scene.add( mesh );
} );

Clear cache

After unzipped, loader instance will store the data. When you don't need the data, you can clear stored cache.

To clear single cache

myImg.onload = function () {
  loader.clear( 'foldername/pict.jpg' );

To clear all cache (sort of its destructor)