The file upload button below, when clicked, allows the user to select a .GIF file, uploads it, and displays it on this web page, all using an algorithm implemented in JavaScript, rather than the web browser's built-in image processor. To see the source code, visit http://thiscouldbebetter.wordpress.com/2014/06/13/a-gif-image-viewer-in-javascript.

You'd never actually need a JavaScript GIF viewer, of course, because any web browser that implements JavaScript already knows how to load and display GIFs just fine. However, if you, like me, are interested in knowing more about the structure of a GIF file, and how it works at the bits-and-bytes level, this code is for you.

My original intent was this code was to use it as a basis for an online animated GIF editor. Because, you know, there aren't nearly enough animated GIFs on the internet. But at the moment, it can only load static images, and there are some additional bugs besides. One big one is that it doesn't seem to understand how to handle black pixels, at all. For example, if you drew a rainbow on a white background in Microsoft Paint, drew a single black line across it halfway down, and saved it as a GIF, and opened it with this program, nothing below that line would look even remotely right. Something to do with my decompression algorithm, I guess. If anyone out there can figure out how to fix it, I'd appreciate the help.