Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

npm file size is smaller when downloaded through unpkg CDN

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:
enter image description here

Size on my local machine when installed via npm (link, version 0.0.180):

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>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/

enter image description here

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading