Disclosure: Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

News

You Really Don’t Need All That JavaScript, I Promise

JavaScript is a pillar of the Web. But like any tool, it involves tradeoffs that developers must keep in mind.

Every week, in the context of our Web Development and JavaScript bootcamps, a new guest addresses our developers-in-training on a topic related to web development and its practice.

Previously, we listened to Prof. Barbara Oakley and software engineer Zach Caceres talk about the neuroscience of learning in programming. GitHub engineer Rizèl Scarlett introduced us to Git and GitHub. And Booking.com engineering manager Parham Doustdar explained the importance of inclusive web design.

This week, developer extraordinaire Stuart Langridge joined us to talk about JavaScript, or rather, to make the case that you might not need as much JavaScript as you think.

(Stuart’s presentation reminded me of Bruce Lawson’ excellent talk during our inaugural bootcamp, which focused on the origins of HTML and its accessibility benefits, and that I also strongly recommend.)

Ubiquitous JavaScript

JavaScript is one of the components of the tools trifecta that underpins the web: there’s HTML, there’s CSS, and, well, there’s JavaScript.

We tend to think of HTML as the skeleton of a web page. CSS is the means by which we style the page: we dress the skeleton, so to speak. And JavaScript adds interactivity to the page: it makes the skeleton move — though I’m stretching the analogy a tad.

As a bona fide programming language, JavaScript is very powerful. It can do a lot of stuff. So it can be tempting to use it to do everything, including things for which plain HTML and CSS would suffice.

And as web development has continued to evolve — quite fast, at that — and expand into an ever-changing tapestry of latest-and-greatest tools, this tendency to rely on JavaScript for everything has only become more pronounced. But JavaScript has its tradeoffs.

JavaScript Tradeoffs

Like any tool, JavaScript has strengths and weaknesses. Among others, Stuart explains that:

  • JavaScript can significantly increase the time it takes to show a page. Browsers are just really good at rendering HTML. JavaScript can cause delays.
  • JavaScript code can add bulk to your website and hog bandwidth. This can impact it in terms of accessibility. Not everyone has good internet.
  • JavaScript processing can slow down your website, again, impacting accessibility. Not everyone has a powerful and modern device.

Leveraging JavaScript is all about knowing when to use it and when not to. As Stuart puts it:

Write HTML and then augment it [using JavaScript], rather than writing a bunch of JavaScript that incidentally generates HTML.

Stuart goes on to explain that part of the reason developers tend to over-rely on JavaScript is because there’s a general lack of awareness about HTML’s latest developments and capabilities.

For instance, did you know that you can code a text input that doubles as a drop-down using only HTML? I certainly assumed you’d need JavaScript for this, but it turns out, you don’t. 

What about creating an animated image carousel? You can do that too simply with HTML and CSS. To learn how to do that, and to understand how to leverage JavaScript appropriately, I encourage you to watch Stuart’s talk below.

Manoel Cortes Mendez Profile Image

Manoel Cortes Mendez

Software engineer and online graduate student in computer science passionate about education, technology, and their intersection.

Comments 0

Leave a reply

Your email address will not be published. All comments go through moderation, so your comment won't display immediately.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Browse our catalog

Discover thousands of free online courses from top universities around the world like MIT, Stanford, and Harvard.

Browse all subjects