💾 Archived View for xchg.cc › posts › bggp4.gmi captured on 2023-11-04 at 11:06:09. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-07-22)
-=-=-=-=-=-=-
This year I finally managed to complete an entry for BGGP. It's nothing fancy, just a quick take on a self-replicating HTML file. The challenge is a self-replicating file which must make one copy of itself, not run that copy, and display or output the number 4. I figured a self-replicating HTML wouldn't be too much trouble, but seeing just how small I could get it would be interesting, for sure.
My final result is a 123 byte file, which displays the number four in the browser, and downloads an exact copy of itself to a file named 4 in your downloads directory.
<body>4<script>d=document;f=d.createElement('a');f.href='data:;,<body>'+d.body.innerHTML;f.download='4';f.click();</script>
We are able to get this as small as it is by using the variable d to represent document at two places in the file, not specifying a data type in the download, and not closing the body tag. I am still hunting for other possibilities to shave off another byte or two.