📜 ⬆️ ⬇️

Compression using canvas and PNG images

Note: below is the translation of the article “Compression using Canvas and PNG-embedded data” . The author proposes to court readers another way to load the JavaScript library in the client browser, transferring a minimum of data. For this, a PNG image and a canvas object are used. My comments further in italics.

Compressed JavaScript library as a PNG file

Recently, I had an idea that you can store the original Javascript code in a PNG image, and then retrieve it via the getImageData() method of the canvas . Unfortunately, this now means that only this approach will work only in Firefox , Opera Beta and the latest WebKit builds. No one has yet indicated to me how much gzip is ahead of this method in terms of compression, I want to immediately say that the method in question cannot be a practical alternative to physical compression. A little earlier today, I already wrote about the compressed version of the 8Kb Super Mario script for which this technique was used ( for more details, see the article about encoding ). Here I will give only some details about the real state of affairs.
')
read further on webo.in →

Source: https://habr.com/ru/post/31607/


All Articles