TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Monospace: A JavaScript demo in 1021 bytes, winner of the demo competition

409 pointsby pekkoover 4 years ago

33 comments

nneonneoover 4 years ago
The <i>real</i> version of this, which is actually 1021 bytes, is here: <a href="http:&#x2F;&#x2F;www.p01.org&#x2F;MONOSPACE&#x2F;monospace.htm" rel="nofollow">http:&#x2F;&#x2F;www.p01.org&#x2F;MONOSPACE&#x2F;monospace.htm</a>. It uses the very clever trick of compressing the JavaScript code as the pixels of a PNG image (which uses Deflate internally), then including the page itself in an &lt;img&gt; tag and decompressing the JS code from the resulting pixels.<p><i>Unfortunately</i>, the developer made a bit of a mistake when uploading this file: it appears to have been uploaded in <i>ASCII</i> mode rather than <i>binary</i> mode, meaning that all the 0x0d (CR) bytes in the file have gone missing (an artifact of the standard &quot;CRLF -&gt; LF&quot; translation performed in text mode uploads). Therefore, it doesn&#x27;t work: all you get to see is a screenful of binary junk. (Author, if you&#x27;re seeing this - it&#x27;s hopefully an easy fix!)<p>I&#x27;ve uploaded the correct version (obtained from <a href="http:&#x2F;&#x2F;www.p01.org&#x2F;MONOSPACE&#x2F;monospace.zip" rel="nofollow">http:&#x2F;&#x2F;www.p01.org&#x2F;MONOSPACE&#x2F;monospace.zip</a>) here: <a href="https:&#x2F;&#x2F;robertxiao.ca&#x2F;misc&#x2F;monospace.htm" rel="nofollow">https:&#x2F;&#x2F;robertxiao.ca&#x2F;misc&#x2F;monospace.htm</a>. This works out-of-the-box on Firefox (modulo being really slow, thanks to <a href="https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1190398" rel="nofollow">https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1190398</a>), but fails on newer Chrome because of click-to-play audio. You&#x27;ll have to &quot;allow&quot; my site under chrome:&#x2F;&#x2F;settings&#x2F;content&#x2F;sound, then refresh.<p>But! Once you&#x27;ve jumped through those hoops, you can appreciate the real ingenuity that manages to pack this demo into a cool 1021 bytes (the compatible version that most of you would have seen is much larger, at 2338 bytes).
评论 #24829970 未加载
评论 #24827204 未加载
评论 #24825458 未加载
SandmanDPover 4 years ago
Because the rest of the commentors in this thread seem to not be reading the article, there&#x27;s a performance issue in Firefox due to the following unresolved bug: <a href="https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1190398" rel="nofollow">https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1190398</a>
评论 #24829407 未加载
评论 #24869558 未加载
评论 #24824563 未加载
rpastuszakover 4 years ago
OK, this is really weird, but I closed the browser tab with the demo ca. 1 minute ago and can still hear the music. I&#x27;m on FF&#x2F;Big Sur.
评论 #24825957 未加载
评论 #24827669 未加载
评论 #24825442 未加载
评论 #24827425 未加载
评论 #24826332 未加载
评论 #24825190 未加载
评论 #24825212 未加载
评论 #24843587 未加载
评论 #24825639 未加载
radoover 4 years ago
It was hard to get to a working demo and here it is: <a href="http:&#x2F;&#x2F;www.p01.org&#x2F;MONOSPACE&#x2F;monospace-compatible.htm" rel="nofollow">http:&#x2F;&#x2F;www.p01.org&#x2F;MONOSPACE&#x2F;monospace-compatible.htm</a>
评论 #24824573 未加载
评论 #24824494 未加载
baneover 4 years ago
This won the Assembly 2020 1kb demo competition. There are some truly mind-blowing entries, including the 2nd place entry which features multiple types of spaceships and a stargate, with audio.<p><a href="https:&#x2F;&#x2F;www.pouet.net&#x2F;party.php?which=7&amp;when=2020" rel="nofollow">https:&#x2F;&#x2F;www.pouet.net&#x2F;party.php?which=7&amp;when=2020</a>
评论 #24826608 未加载
A_Venom_Rollover 4 years ago
For people not able (or willing) to run the demo themselves, it can also be seen on YouTube in a 3 minute clip [0]. It keeps amazing me how much people can accomplish with less than a KB of code.<p>[0] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=2HN139WkcCY" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=2HN139WkcCY</a>
评论 #24824787 未加载
mrspeakerover 4 years ago
This is similar (but much much better) to a demo I was making for JS1K a bunch of years back: <a href="http:&#x2F;&#x2F;mrspeaker.github.io&#x2F;js1k16&#x2F;" rel="nofollow">http:&#x2F;&#x2F;mrspeaker.github.io&#x2F;js1k16&#x2F;</a><p>My &quot;big idea&quot; was to use the speech synthesis API (I still liked how I used it)... but I thought it was funny, because it felt like cheating to say &quot;1K&quot; when it relied on so many megabytes of APIs!
评论 #24829143 未加载
评论 #24825802 未加载
评论 #24825718 未加载
评论 #24828058 未加载
p01over 4 years ago
Glad you like it :)<p>-- p01, author of MONOSPACE
评论 #24827144 未加载
评论 #24829678 未加载
mmanfrinover 4 years ago
Tanked my firefox instance, which I closed, and the noise from the page continued. Do no open this in firefox.
评论 #24824856 未加载
评论 #24824752 未加载
评论 #24826821 未加载
评论 #24824559 未加载
ricksharpover 4 years ago
Amazing! Very impressive how you got all the details in. I&#x27;d be interested in hearing what the development process is like.<p>Do you work directly in the minified code, or do you create the demo in normal code first then look for ways to minimize it?
评论 #24825080 未加载
bulkaover 4 years ago
I, for one, liked the &quot;firefox version&quot; of the demo. No way to close, mute or go back. And after a minute someone starts talking to you. Pretty cool.
评论 #24825224 未加载
评论 #24824903 未加载
rsiqueiraover 4 years ago
Here are other visual JS Demos created by p01 and others using just 140 characters of code (or less!): <a href="https:&#x2F;&#x2F;www.dwitter.net&#x2F;top&#x2F;year" rel="nofollow">https:&#x2F;&#x2F;www.dwitter.net&#x2F;top&#x2F;year</a><p>Dwitter is a collection of amazing short JavaScript codes that can be explored, remixed and voted &quot;awesome&quot;. It works like a living portfolio of short code&#x2F;graphic creations where one can learn by exploring other people&#x27;s code.
algiegover 4 years ago
To everyone running it in Firefox: &quot;Unfortunately, Mozilla still hasn&#x27;t fixed the performance bug 1190398 around ShadowBlur, filled for BLCK4777 5 years ago.<p>Therefore you need to use a Chromium or Webkit browser to enjoy MONOSPACE live.&quot;
评论 #24824659 未加载
_the_inflatorover 4 years ago
I value p01&#x27;s contribution to the world of optimized code using JavaScript. He is doing this for many years now, and he still keeps pushing the boundaries with creative optimization techniques. This is so cool!
detritusover 4 years ago
It&#x27;s amusing to me that I saw this about 5 minutes after I received a pop up notice from Adobe advising me to uninstall Flash as it&#x27;ll be EoL&#x27;d in a few months.<p>I appreciate they&#x27;re entirely different beasts, but the Monospace demo here definitely IS creative.
3npover 4 years ago
This is amazingly impressive. It boggles my mind how much can be done with so little.
mythzover 4 years ago
Don&#x27;t try this [1] in Firefox, from the article:<p>&gt; Unfortunately, Mozilla still hasn&#x27;t fixed the performance bug 1190398 around ShadowBlur, filled for BLCK4777 5 years ago<p>&gt; Therefore you need to use a Chromium or Webkit browser to enjoy MONOSPACE live<p>[1] <a href="http:&#x2F;&#x2F;www.p01.org&#x2F;MONOSPACE&#x2F;monospace-compatible.htm" rel="nofollow">http:&#x2F;&#x2F;www.p01.org&#x2F;MONOSPACE&#x2F;monospace-compatible.htm</a>
warentover 4 years ago
oh wow, I thought the video was an artistic edit of the program. it was frustrating me because just wanted to see the program, not a filtered, edited trailer. then I realized that&#x27;s the program. this is really mindblowing, the creator is definitely some kind of genius
janOschover 4 years ago
It is amazing how much one can achieve with so little code. I would dare to say that such demos are a kind of...indie art?<p>Can you give us some pointers, which APIs and algorithms did you use to generate the demo? I bet it will be an interesting lesson on math and web
sergeykishover 4 years ago
Function call without parentheses<p><pre><code> c.getContext`2d` </code></pre> invoked as tagged template
Kiroover 4 years ago
People love to bash developers who put up &quot;Chrome recommended&quot; banners, dismissing them as lazy, but when making games and such there are real issues that are impossible to circumvent. This bug is a prime example of that.
评论 #24824954 未加载
评论 #24824897 未加载
auggieroseover 4 years ago
The sounds reminds me a bit of Laurie Anderson&#x27;s &quot;O Superman&quot;.
vardumpover 4 years ago
I was so happy <i>not</i> to see another cheap dismissal here.<p>Too often you have to read how a sizecoded demo uses a ton of system libraries or whatever, completely dismissing the technical achievement.
评论 #24828123 未加载
rendallover 4 years ago
Very impressive. Under 1kb. Astonishing.<p>I love that people keep pushing against the boundaries of what is possible to do. It&#x27;s important work, and so fun!
thelazydogsbackover 4 years ago
Great art piece regardless of size -- I could totally see this playing from a 8mm projector at the Whitney museum in 1968...
debtover 4 years ago
&quot;Finally, yes MONOSPACE is named after the font family used to write the text, to gain a few bytes.&quot;<p>Ha, that&#x27;s amazing.
kebmanover 4 years ago
This made me think of THX 1138, the 1971 science fiction movie by George Lucas. Very nice work!
sabujpover 4 years ago
here&#x27;s the rest of them : <a href="https:&#x2F;&#x2F;archive.assembly.org&#x2F;2020&#x2F;online-1k-intro" rel="nofollow">https:&#x2F;&#x2F;archive.assembly.org&#x2F;2020&#x2F;online-1k-intro</a>
Hnrobert42over 4 years ago
I was put off by the first paragraph. The author could have found a more modest way to introduce the subject.
dpc_pwover 4 years ago
1021 bytes of JS, and 6 million lines of browser code.<p>FTFY<p>These modern demos, using OpenGL and now the whole web browser that are mimicking the rules and sentiment of old 8-bit machines demos, or even later DOS demos, are not the same thing.<p>Oh, this demo has text being spoken ... how was it done ... <i>checks source code</i> ... SpeechSynthesisUtterance . Yeah right, 1021 bytes. :)
j4nt4bover 4 years ago
I&#x27;m getting the same issues as all of the other Firefox users. Guess I&#x27;ll never watch it, because I have a hard policy of never, ever installing Chrome malware on my personal computer.<p>Maybe the title should be changed to &quot;Chrome demo&quot;?
评论 #24824776 未加载
评论 #24824819 未加载
评论 #24824786 未加载
评论 #24825228 未加载
评论 #24825235 未加载
woohoojooover 4 years ago
Who decided to use extremely annoying sounds as the audio track for the first video on the page [1]?<p>I turned it off immediately after hearing its audio.<p>If you want folks to watch a video, allow me to suggest making it as pleasant an experience as possible, at least in terms of the audio.<p>Terrible marketing = marketing that makes your customers&#x2F;prospects&#x2F;audience suffer<p>[1] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=2HN139WkcCY&amp;feature=emb_logo" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=2HN139WkcCY&amp;feature=emb_logo</a>
Theodoresover 4 years ago
The video was lost on me whereas the demo made me think how cool it was.<p>I expected the video to explain what it was but alas no. The video is just the demo running. The demo was brilliant, but, the video of the demo, although practically the same had me wondering quite negative thoughts. I wasn&#x27;t thinking &#x27;how do they do that&#x27;, I was thinking &#x27;this is a bit pretentious&#x27;. It is amazing the difference context makes.
评论 #24825039 未加载
评论 #24824777 未加载