Reputation: 13568
I am serving a web page and want to know how many kbs adding some content would take. Suppose the content is 10,000 characters, how many kbs is that?
I'm not sure what to say because the content encoding for websites is gzip... is there a way to (at least approximately) answer this question for both uncompressed and compressed with gzip?
Upvotes: 0
Views: 992
Reputation: 99687
If you use UTF-8, all basic latin characters are 1 byte, as well as all numbers and most special characters from your keyboard.
Most characters from other writing systems use 2 bytes, but this can become bigger for some combinations of characters. Many Emoji are 4 bytes, but they can be much larger (I've seen 21 bytes, but that's probably not the limit).
Average gzip compression for HTML is 70ish percent? I don't have a source for this.
The book 'War of the worlds' by H.G. wells is 340kb. Less than most images and many npm dependency trees.
This is the type of question that is probably easier to google the answer for than to type it on stack overflow.
Upvotes: 1