Facebook Tweet


JavaScript is not the answer to everything

May 2015

So a young web developer said we should abandon old fashioned HTML4 markup and just use HTML5 to paint the text to a canvas.

I cringed. I told him transmitting text and letting the browser render it natively in the user’s preferred font is very efficient. Transmitting and waiting for JavaScript to render is slow, particularly on mobile. I then said screen readers for disability can’t handle painted text. His answer to that would be to have an XML feed of the text for the screen reader. I asked, “Then why not just have the XML be the main content and let the client render in a way the user likes…. you know, sort of like XHTML was headed?” The problem is because the client’s browser will not render it “correctly”. He wants pixel-perfect replication.

There is a use-case for that, such as web-based games, and HTML5 Canvas is great for pixel perfection, but you want all sites to do this? I said I prefer my laptop’s battery to last 5 hours instead of 2 while browsing. Also, what about bandwidth caps? Users will need to download a font and rendering logic for every single site visited. What about copy/paste and other nice right-click functionality? An HTML5 canvas is essentially an image. He said that can be handled with additional code. Yay, more code to download for every site.

I said, “Why don’t we just re-implement Chromium in JavaScript? Actually, you could have the JavaScript instantiate a Virtual Machine that instantiates Webkit and then have the Webkit receive the markup, launch its own JavaScript engine to render the text? Yes, that is awesome. I’m sure all the Android 2.3 users will love it.

OK, so that last argument was brought to you by Reductio ad absurdum. Regardless, this is simply an all-around horrible idea. Yet, I still don’t think he conceded the point. He is of the new generation of programmers starting web development. Maybe that’s why sites are becoming so bloated and slow. Maybe that’s why some sites break and render a plain white screen with nothing on it (I’m looking at you, Gawker). My guess is because all the content is wrapped in a borked JavaScript routine.

Every language has its use. I recently rewrote a Python server to pure C sockets so it would run faster. This is because Python makes an inefficient server. More than a handful of connections spiked the processor. However, for a Cron job? I wouldn’t think twice about Python. HTML5 Canvas is inefficient at presenting text. If given that project, assuming the goal is just conveying text, I’d rip it out and re-implement it in HTML4. It may be old and boring, but HTML4 is excellent at transmitting text. Google loves fast sites. Users love fast sites.

Right tool for the job.


Dan Nagle is a SW Developer and the founder of NagleCode. His apps have been downloaded hundreds of thousands of times. Contact Dan to speak at your event.

More Posts

Jan 2018: Pay Down Calc v2.0 - A Resource For Consumers and Agents
Jul 2015: Unity Publishing Metrics
May 2015: JavaScript is not the answer to everything
Feb 2015: Abandoning Scripts for Static Pages
Apr 2014: Qt is better than Java.
Oct 2013: The government does not need to make a health website.
Sep 2013: Google Reader may by dying but RSS is not
Jun 2013: Stop writing batch scripts. Start writing AutoIt scripts.
Mar 2013: Goodbye XP Hello Linux Mint
Dec 2012: Your Goals Should be SMART
Apr 2011: Happy 40th Birthday FTP and Farewell
Aug 2010: Breaking the World Record Typing Numbers to Words

Copyright © NagleCode 2007 - 2019.