News and insights • Posted on 29 March 2023

The decline of JavaScript?

JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, and animate images. Over the past decade, front-end technology has seen an incredible increase in JavaScript framework adoption by developers. But due to Google’s PageSpeed analytics negatively scoring JavaScript load time on websites more recently, developers have looked to alternative solutions to improve these scores. 

Here, we assess JavaScript load time, outline how to optimise JavaScript code, and take a look at whether there’s a decent alternative to JavaScript.

Why is JavaScript slow?

JavaScript is not inherently slow, but it can be slower than other lower-level languages for certain tasks. Several factors contribute to this:

  1. JavaScript is an interpreted language, which means that the code is executed by an interpreter at runtime, rather than being compiled beforehand. This can make JavaScript slower than compiled languages because the interpreter has to translate the code into machine code every time it runs.

  2. JavaScript uses automatic memory management, known as garbage collection. While this makes programming easier, it can also slow down performance because the garbage collector has to constantly check for unused objects and free up memory.

  3. JavaScript is commonly used in an event-driven model. This means that the code is triggered by user interactions, such as mouse clicks or button presses. While this can make for a better user experience, it can also make the code slower because it has to constantly listen for events.

  4. JavaScript has limited support for multithreading, which means that it can’t take full advantage of multiple processor cores. This can make JavaScript slower than languages that are designed for parallel processing.

Despite these factors, JavaScript has come a long way in terms of performance in recent years. And with advances in hardware and software technology, it continues to improve. What’s more, there are plenty of steps you can take to optimise it.

How to optimise Javascript code

So, does JavaScript slow down websites? The short answer is: if the JavaScript code is poorly optimised or contains errors, it can lead to slow loading times and negatively impact website performance. 

Simple methods to speed up JavaScript load times are essential knowledge for web developers:

  1. Delete unnecessary JavaScript, such as custom code for widgets that are no longer in use.

  2. Downsize or remove your JavaScript library. Often, the same results can be achieved without libraries and with little extra effort. Alternatively, consider loading only part of the library, for example with jQueryUI.

  3. Minimise blocking code. If JavaScript code is placed in the head section of a webpage, it can block other resources from loading until the code has finished executing. This can slow JavaScript load time and lead to a poor user experience.

  4. Consider the performance impact of third-party scripts, such as those from social media platforms or advertising networks. These can slow down website loading times if they’re not optimised, or take a long time to load.

Is there a viable alternative to Javascript? 

Lately, new fledgling frameworks such as Astro, Marko and Qwik, have taken the web development world by storm, all of which can be used in conjunction with JavaScript for a more optimised experience. By compiling components and routes down into pure HTML, PageSpeed scores have seen a sharp increase. 

Astro framework

Anyone working in a marketing agency will be familiar with the age-old battle between designers and web developers. Designers want websites to look incredible, with all the bells and whistles, but web developers know this can slow the site down, and their priority is ensuring websites are as fast and slick as possible. Enter the Astro web framework, which enables a balance between the two. 

Designed for speed, Astro allows users to pull content from anywhere and serve it fast. 

The Astro framework strips the JavaScript surrounding interactive UI components (such as videos and hover effects) away, leaving small, isolated ‘islands’ in a sea of static, non-interactive HTML. Unused JavaScript is replaced with lightweight HTML, guaranteeing faster loads and time-to-interactive (TTI). As early adopters of the Astro framework, our crew members actively talk to the Astro team to discuss what we like and where we feel the framework could be improved, helping to shape how it works. 

Marko framework

The Marko framework is HTML re-imagined as a language for building dynamic and reactive user interfaces. Just about any valid HTML is valid Marko, but Marko extends the HTML language to allow building modern applications in a declarative way.

Used to power high-traffic websites like ebay.com (which actually created Marko), this relatively new (but trusted) framework is easily scalable and tailored to wherever the code is going to run. It’s not a static site generator, rather it’s used to create web apps. At the moment, it’s not something we really use at TBB, as it’s more suited to businesses that might need to display data in real time, such as FMCG brands.

Qwik framework

Qwik takes a new approach to performance optimisation. This framework introduces the concept of ‘JavaScript Streaming’ where the page loads instantly and required JavaScript chunks are prefetched in a separate thread, similar to ‘buffering’ in video streaming. The prefetched code only executes upon user action, in a process called ‘Lazy Execution’. This performance boost requires no manual effort or decision-making from the developer, as this feature is pre-built into Qwik. In addition, Qwik’s Optimizer can generate JavaScript based on real-user metrics to understand the optimal way to bundle commonly used modules.

So, is JavaScript on the decline? No – it’s just that web developers (including our own) are discovering new ways to use it in order to achieve perfectly balanced and optimised websites. Think you could add to our ever-growing web development expertise? Get in touch about potential careers at TBB.

If you want to keep up to date with the crew, don't forget to sign up to our newsletter to benefit from digital marketing expertise, as well as exciting opportunities to improve your business' performance.

Back to the news hub

Written by Alice MacLaverty

Resident wordsmith Alice is dedicated to creating top-quality content that turns heads, builds audiences, gets clicks, and makes money.

News and insights

The benefits of market research projects: gaining a competitive edge

From fostering endless content creation opportunities to building brand awareness, market research projects can give brands a major boost.

Read more
News and insights

Speaking as one: The powerful synergy between PR and marketing

How does PR and marketing work together? Explore the powerful synergy between these services, and how integrating them enhances brand awareness and credibility.

Read more
View more in the hub

Ready to start your next big project?

Let's talk
Great place to work logo

Contact

The Bigger Boat
Suite 7, The Watermill
Wheatley Park
Mirfield, West Yorkshire
WF14 8HE

Talk to us

Registered Company No 7103268. VAT No 985 1811 91