<!DOCTYPE html> <html> <meta charset="UTF-8"> <script src="https://cdn.jsdelivr.net/pako/1.0.3/pako.min.js"></script> </html> <body> <input id="test" type="file"/> <script> 'use strict'; let fileinput = document.querySelector('#test'); fileinput.onchange = () => { console.log('read file.'); let file = fileinput.files[0]; let fileReader = new FileReader(); fileReader.readAsArrayBuffer(file); fileReader.onload = () => { console.log('start compress.'); let deflate = pako.gzip(fileReader.result, { level: 3}); console.log('end compress.'); console.log(deflate); } } </script> </body>