question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compressing large html with style and script tags

See original GitHub issue
var express = require('express')
var compression = require('compression')

var app = express()
app.use(compression())

app.get('*', renderHTML)

function renderHTML() {
  res.status(200).send( { humongous HTML file with style and script tags } )
}
screen shot 2017-10-20 at 3 58 11 pm

I’ve followed the docs and received a response that has a content-encoding = ‘gzip’ flag on it. However, the size of the response is the same as when I comment out all the compression code. Gzip-checking websites also tell me that the response really isn’t gzipped.

The humongous HTML content is populated after going through several other APIs and collecting a bunch of data.

Could the issue be due to the HTML response containing css and javascript that isn’t being gzipped? Do I have to separate the content I’m sending?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
dougwilsoncommented, Nov 3, 2017

If Content-Encoding is gzip, then it is compressed. Chrome’s size column is bugged in that if a response is Transfer-Encoded: chunked it will show the decompressed size there instead of what was over the network. Use Wireshark to measure what was actually going over the network, please.

1reaction
dougwilsoncommented, Nov 3, 2017

The uncompressed size is 318255 bytes but if you look at the network traffic over Wireshark, you’ll see the server is sending the binary gzip and that it’s only 43533 bytes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reduce the size of HTML, CSS, JavaScript, PHP and Smarty ...
Select a x/html code type in such case. Select CSS when you want to compress just Cascading Style Sheets (CSS) code as it...
Read more >
How to compress HTML and other website code - Ryte
Both methods are great for compressing HTML, CSS, and JavaScript files. In addition, minifying is another useful way to keep the code slim....
Read more >
What is the best method to reduce the size of my Javascript ...
Try web compressor tools from Boryi to compress your standard HTML file (without Javascript code and css code embedded, but ...
Read more >
How to Optimize HTML to Boost Web Performance
HTML Delivery Tip #1: Clean up HTML so it is concise · Don't use inline styles. · Don't use inline scripts. · Reduce...
Read more >
Reduce HTML5 file size - Studio Help - Google Support
An HTML5 creative commonly refers to ads created with HTML, CSS, and JavaScript. ... The size of the Enabler script is 25 KB...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found