Sunday, 1 April 2018

Trying (and failing) to serve gzip javascript in node!

Without gzpping the javascript bundle, it works 100% correctly. But when I serve the gz js version the file loads but then the javascript breaks and I get the error: "Cannot read property 'classList' of null" It looks like some parts of the gz js work though! As I get some console.logs running.In my server.js I'm running this:app.use(expressStaticGzip(path.join(__dirname, "public"))); using the expressStaticGzip package.In Webpack I'm using the Compression Webpack plugin and running: new CompressionPlugin({ asset: "[path].gz[query]", algorithm: "gzip", test: /\.js/, threshold: 10240, minRatio: 0, deleteOriginalAssets: true }) In my main templating file I'm loading the js like this: script(src="/dist/bundle.js") Whats odd is that some parts are working and the gzpped version seems to be breaking other parts? Any help much appreciated!

Submitted April 01, 2018 at 06:44PM by laura808s

No comments:

Post a Comment