Quines

Quines are programs whose only purpose is to print out their own source code. It cannot be done by just reading the source code from the disk and printing it, of course; the compiled program must contain all information necessary to do that.

Several years ago I was quite interested in writing quines. Not for any particular reason; it was just a cool thing to do. (In case you didn't know I am a big nerd.)

Here are some I made recently. You only need to copy and paste them into a new file, then run the program, and the source code should be output again.

HTML/JavaScript

Recently I wondered what a HTML quine would look like, so I set out to make one. In the end I didn't make only one: I made four. Three of them are legitimate quines, the fourth one was made by cheating.

This is the most classic, straightforward approach to making a quine in any language: just store a copy of the source in some variables using some kind of encoding, then print out everything in both encoded and decoded form. The program is 216 characters long.

If you can make shorter HTML/JavaScript quines, I'd like to know about it. I know that those are not the shortest possible HTML quines. The shortest one is an empty file, which displays as an empty webpage. But that is super-cheating! :)