View on GitHub


CodeImage is a way to package javascript code into an image. The javascript can be extracted and run as if it was located in a script tag.

Download this project as a .zip file Download this project as a tar.gz file

What is a CodeImage?

A codeimage is an image that is actually javascript code. When a webpage that has a codeimage is loaded, the javascript code contained in the image is extracted and run. It is a novel way to distribute your code and your code won't be immediately viewable to curious eyes.

A codeimage can contain javascript and/or images. The intent is to have all the code and art assets of a project packaged up in a single object. Javascript code compressed to about 1/3 the original size in a codeimage, however images do not compress at all and, in fact, may be a useless feature.

The function to decode the codeimage and launch the resulting code is about 700 bytes. Decoding large images can be rather slow on older machines. I currently have one project that contains 40kb of javascript encoded in a 20kb PNG.

If you want to try out the encoding yourself, go here and try it