What is JavaScript used for?

I want you to imagine yourself diving out of an aeroplane at 10,000 metres above sea level after spending all day in a library. What does that feel like?

It feels like a big change. Even for book lovers – and I am one – the sensation of the wind rushing through your hair and the sight of the ground rushing up to meet you is likely to get the heart pumping much faster than even the most exciting adventure novel.

The difference between being in a comfortable but admittedly restful library and skydiving is rather like the contrast between the Internet before and after JavaScript. Some of our readers might be old enough to remember the Internet of the late nineties. It was exciting because it was new and contained all kinds of information we’d never had access to before.

But it was – looking back – a little dull, too. At least, as far as presentation and interactivity was concerned. This wasn’t just because of the low speeds associated with dial-up Internet.Web pages were basic and most of your interaction with a site involved navigating between different text-heavy pages.

Interactive games, maps, and other dynamic features were almost unheard of.

So, what happened?

JavaScript happened.

What is JavaScript?

JavaScript (JS) is a programming language that underpins most of the dynamic, interactive content you see on the modern Internet.

But this raises another important question. What is dynamic content?

Dynamic content is any content that can change on a webpage without the need to hit refresh. To make the difference between static and dynamic content clearer, let’s look at an example of each.

JavaScript symbol

What is Static Content?

If you have to hit ‘refresh’ to see new information, you’re viewing static content. Let me tell you a sad story to explain further.

When I was in an English secondary school during the 2002 football World Cup (okay, soccer, for you Americans – and yes, I’m showing my age) we were all very frustrated not to be able to watch the matches live. Instead, we had to sit in class and try to focus on trigonometry.

It wasn’t just the kids who were frustrated, either. The teachers hated it, too. But this was back in the days before most schools – or even homes and businesses – had sufficiently fast internet connections for live streaming of television over the Internet.

Most broadcasters didn’t even offer a live streaming feature, anyway. The best you could get were usually short clips of important moments a few seconds long.

But they did have blogs. If we students behaved ourselves, our teacher – who was keeping an eye on the football on the BBC Sport website – would tell us how the matches were going. This being the World Cup, things usually weren’t going great for England.

To see new events, the teacher would have to refresh the webpage for the blog about the match we were following. This was because the page was not using JavaScript to enable dynamic content. Because the content was static, the teacher had to refresh the page and hope that whoever was managing the website had updated the page with new information.

The new words that appeared on the page after each refresh announcing that – yes – Brazil had scored again, were an example of static content. As were the pictures of England fans in tears after having spent hundreds of pounds and travelled all the way to Japan only to see their team lose. Cue the sad music.

What is dynamic content?

Dynamic content is any on page feature that doesn’t require a human to click ‘refresh’ for the information displayed to update. To make this clearer, let’s leave 2002 behind us and zip forward a very busy eighteen years.

It’s then night of November 3rd 2020. The United States’ presidential election is being held. As is normal, it’s a nail-biter, whatever your politics. But unlike most recent races, we didn’t get a clear result the next day. In fact, despite Biden having an early advantage, it wasn’t until November 7th that most national American media organizations were willing to call the election in his favor.

While many people will have been following the election on TV, staying up all night on a diet of coffee and sugary snacks, most young people – assuming they were interested – followed the news on mobile native news apps or social media.

When it comes to following the news, it’s no secret that Twitter is one of the most popular sources among the politically engaged population. Those interested in following how the tense situation developed could follow along there without furiously mashing the refresh button.

Why? Because since a 2017 update, Twitter has been able to update replies, likes, and retweets dynamically. This feature is supported by JavaScript. For the end user, that means they can simply watch the conversation evolve and the likes tick up simply by, well, watching. No refreshes required.

So when a particular President tweeted something alarming, confusing, outrageous, or all three, all an astonished Twitter user needed to do to keep up was sit in front of their screen and gaze in horror or amusement at the unfolding chaos.

In a way, you could say JavaScript is directly responsible for keeping citizens informed about what’s happening in the world with a greater immediacy than ever before. Or at least, giving them faster insights into what public figures and random strangers on the Internet have to say about current events.

Thanks, JavaScript. Dynamic content has never led to more discontent!

Of course, there are many other examples of dynamic content. From responsive maps for finding your way to a highly-rated Mexican restaurant, to 3D models, to interactive online browser games, JavaScript is serving up content that changes every day.

What JavaScript is used for?

JavaScript is a programming language used to write code capable of delivering content dynamically. If you don’t know what dynamic content is, check out the above section.

Because so much of the modern Internet is required to be interactive in some way, it’s perhaps unsurprising that JavaScript is used on client-side programming for 98% of all websites.

Client-side programming is responsible for the code that runs in the browser of the end user. This makes sense because JavaScript is extremely good for writing code relating to interfaces and how information is displayed.

Another reason for JavaScript’s wide adoption is its flexibility. The language can be used in a rich variety of contexts. We’ll explore the key examples of these now.

Building interactive websites and webpages

As we’ve seen, one major use of JavaScript is to build highly interactive websites and web pages. If you just want to display static text and images, it’s entirely possible to develop a website without using JavaScript.

Indeed, that’s how most of the web used to be – a dry series of web pages written in HTML connected by hyperlinks with few interactive elements to speak of.

But as time has gone on, users have increasingly come to expect more from the sites they visit. Some of that is down to better site design and the increasing professionalization of web development. While creating a great-looking site used to be a challenge, an increasing number of platforms – from WordPress to Squarespace – have made it simple to create a modern-looking site without writing so much as a line of code. And these platforms let users build, add and edit content dynamically with features like drag-and-drop editing on content management systems built with JavaScript.


Creating web and mobile applications

Do you want me to develop an app?

Through various popular frameworks like React Native, Node.js, React, Angular, and Vue, JavaScript is often used to create web and mobile applications.

For example, the fintech (financial technology) space is one of the most lucrative areas of digital product development. But if you thought those tech-savvy finance bros were using some kind of special, only-for-the-super-rich programming language to build their platforms, you’d be wildly off the mark.

Take PayPal. Built in JavaScript via the totally free-to-use Node.js open source server environment, PayPal used the language to build the customer-facing side of their applications.

Interestingly, the case of PayPal shows how JavaScript doesn’t have to only be used for client-side work. According to Jeff Harrel, PayPal’s Senior Director of Payments Products and Engineering, the company chose Node.js in part because it would let them use JavaScript to build the server applications, too. That way, they could consolidate their tech stack and bring all their engineering specialties into a single team.

As we said, JavaScript is flexible.

Developing browser-based and standalone games

It’s entirely possible to build a video game on JavaScript and sell it for actual money.

While many games are relatively simple and free to play, like the racing game HexGL, some paid games have met with critical acclaim.

The sci-fi point-and-click thriller Gods Will Be Watching was built by Deconstructeam originally as part of a JavaScript coding challenge. It turned out to be good enough for people to want to part with money for, and still has a rating of Very Positive for recent reviews on Steam, despite having been released all the way back in July 2014.

One of the main reasons JavaScript is such a great option for developing games is its focus on interactivity. Imagine a browser-based game where you had to click to refresh the page whenever you needed new content!

Get started with your JavaScript project

As we’ve seen JavScript – among many other potential uses – serves as the foundation for modern web development. An Internet without JavaScript would be unrecognizable to most younger web users. For those of us who do remember the pre-JS Internet, I don’t think I’m alone in saying that I’d rather not go back to those days.

If you’d like to take advantage of recent innovations in software development – including the exciting Jamstack architecture – we’d like to help. You can contact us whether you’re looking for advice on how to get started with a development project or you’d just like to get things moving. We’ll be happy to hear from you.

Develocraft is a Jamstack-oriented company

Rafał Kruczek

Hi there, dear reader! I'm the content guy at Develocraft. Here to be nerdy, talk about tech challenges for any business of any size, and share the knowledge. If you want to do something together, exchange stories or tell me the most inappropriate joke you can think of - feel free to hit me up on LinkedIn.

  • 15
    min. read
  • July 12, 2023