I have a file inside my npm package that is 307kb of size. When I download that file through unpkg – that very same file is 73.2Kb. I am quite puzzled on how the same file downloaded through the network is smaller.
Here is the size when downloaded through the network – link:
Size on my local machine when installed via npm (link, version 0.0.180):
>Solution :
The file itself is 307 KB on disk, but when you download it through unpkg it is compressed, so it downloads about 4x as fast. Once the browser downloads the compressed version, it will decompress it to make it usable JavaScript.
The standard compression algorithm/encoding used is gzip
Diagrams from https://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/