f in x
> cd .. / HUB_EDITORIALE
Sviluppo di siti web

ES2024 JavaScript — New Features, Performance and Use Cases for Developers

[2026-06-21] Author: Ing. Calogero Bono

Why Upgrade Your JavaScript to ES2024?

Have you ever opened a web app and felt that one‑and‑a‑half second delay? It happens when JavaScript is written with decade‑old techniques. We, at Meteora Web, see it in projects that come to us: slow forms, unresponsive carts, pages that block the main thread. JavaScript has evolved, and not updating your stack costs you lost users and revenue. With ES2024 you get tools that cut code weight by 30–40% and make async manageable. This is not academic luxury: it directly impacts your bottom line.

What Changes with JavaScript ES2024 Compared to ES2023?

The ECMAScript 2024 specification (15th edition) brings concrete features, not just syntax. The most notable is Array.prototype.groupBy and groupByToMap: grouping objects by key without lodash or manual reduce. Also Promise.withResolvers simplifies creating promises from outside, useful for non‑standard callbacks. And Atomics.waitAsync for non‑blocking waits in workers. Every year TC39 pushes JavaScript to be more predictable and performant. We started using groupBy immediately: cleaner code, fewer bugs.

Array.groupBy: a real‑world example

const orders = [
  { product: 'mouse', category: 'peripherals', qty: 2 },
  { product: 'keyboard', category: 'peripherals', qty: 1 },
  { product: 'monitor', category: 'displays', qty: 1 }
];

// ES2024
const grouped = Object.groupBy(orders, ({ category }) => category);
console.log(grouped);
// { peripherals: [mouse, keyboard], displays: [monitor] }

You used to write a reduce with key checking. Now it's native, fast, readable. If your e‑commerce groups orders by category, this feature alone saves dozens of lines.

Sponsored Protocol

Promise.withResolvers

function waitForEvent(target, eventName) {
  const { promise, resolve, reject } = Promise.withResolvers();
  target.addEventListener(eventName, resolve, { once: true });
  // handle timeout with reject
  return promise;
}

No more external variables to resolve a promise. Cleaner code, fewer closure bugs.

How to Handle Async with async/await in ES2024?

async/await is not new to ES2024, but with new APIs (Promise.withResolvers, Atomics.waitAsync) async handling becomes even more robust. We use async/await everywhere: API calls, file reads, animations. The most common problem? Unhandled errors. An await without try/catch crashes the entire flow. Here's the rule we apply in our projects: every async function must have a try/catch or be called with .catch(). It's not just good practice: it's loss of data and angry customers prevention.

Error handling pattern with async/await

async function fetchOrders(userId) {
  try {
    const response = await fetch(`/api/orders/${userId}`);
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return await response.json();
  } catch (error) {
    console.error('Cannot load orders:', error);
    // In production: remote log + friendly UI
    return { error: 'Service temporarily unavailable' };
  }
}

Note the use of native fetch and HTTP status check. Many forget that fetch does not throw on 404 or 500, only on network errors. Checking response.ok is mandatory.

What Are the New Features of ES2025 for Daily Development?

As we write, ES2025 is a candidate, but some proposals are already stable. The most discussed: Pattern Matching (inspired by functional languages). Though not official yet, the ecosystem is preparing. Other features that landed: Iterator helpers (map, filter, reduce on iterators), Set methods like union/intersection/difference. We are already using them with polyfills. The benefit? More declarative code, fewer external dependencies.

Sponsored Protocol

How to Use ES Modules for Scalable Code?

ES Modules (import/export) have been the standard since ES2015, but many web projects still ignore them and use script tags with global variables. Result: namespace collisions, implicit dependencies, exploding bundles. We, at Meteora Web, build every project with ES Modules from day one. Why: each file explicitly declares what it imports and exports, and the bundler (e.g., Vite, Webpack) can tree‑shake to remove dead code. If you have a site with 50 spontaneous scripts, switching to modules reduces JS size served by 20–30%.

Lazy loading with dynamic import()

// Load the map only when the user clicks the button
button.addEventListener('click', async () => {
  const { initMap } = await import('./mapModule.js');
  initMap();
});

This technique avoids loading unused code at startup. Google values Interaction to Next Paint (INP), and lazy loading is one of the most effective ways to improve it.

How to Manipulate the DOM Without jQuery with Modern JavaScript?

jQuery was a cornerstone, but today native DOM API (querySelector, classList, dataset) covers 99% of cases. Why keep loading 30KB of library? We have completely replaced it in new projects. Here's a practical comparison.

// jQuery
$('#menu').addClass('active').slideDown();

// Native JavaScript
document.getElementById('menu').classList.add('active');
// For animations we use CSS transition or Web Animations API

For complex animations, Web Animations API offers better performance because it runs on the compositing thread. Example:

Sponsored Protocol

element.animate([
  { opacity: 0, transform: 'translateY(-20px)' },
  { opacity: 1, transform: 'translateY(0)' }
], { duration: 300, easing: 'ease-out' });

No jQuery, no blocking JavaScript animations. The browser optimizes itself.

How Does the Event Loop Work and Why Is It Crucial for Performance?

The event loop is the heart of single‑threaded JavaScript. Understanding microtasks (Promise.then, MutationObserver) and macrotasks (setTimeout, click event) lets you avoid UI freezes. A common mistake: performing heavy operations in the main loop, e.g., processing 10,000 items with a for loop that updates DOM on each iteration. Solution: chunk the work or use requestAnimationFrame for visual deadlines, or Web Workers for CPU‑bound tasks.

Example with requestAnimationFrame for smooth animations

function smoothUpdate() {
  // DOM update based on timestamp
  requestAnimationFrame(smoothUpdate);
}
requestAnimationFrame(smoothUpdate);

Do not use setInterval for animations: it accumulates calls when the tab is in background and wastes resources.

How to Use Fetch API and Handle HTTP Responses?

Fetch API is the successor to XMLHttpRequest, but many use it poorly. They forget to clone responses (consumable only once) or to handle the body as a stream. In our daily work, we follow these practices:

  • Use response.clone() if you need to read the body in multiple places.
  • For large file downloads, use response.body with ReadableStream to avoid keeping everything in memory.
  • Always check response.ok or response.status.
async function downloadFile(url) {
  const response = await fetch(url);
  if (!response.ok) throw new Error('Download failed');
  const reader = response.body.getReader();
  // process chunk by chunk
}

LocalStorage vs SessionStorage vs Cookie: What's the Difference?

Each technology has its purpose. LocalStorage (up to 5–10MB) persists after browser close; SessionStorage loses data when the tab closes; Cookie (max 4KB) is sent with every HTTP request. We often see localStorage used for sensitive data (JWT tokens): wrong, because it's accessible via XSS. Cookies with the HttpOnly flag are more secure. Here's our rule:

Sponsored Protocol

  • LocalStorage: UI preferences, non‑sensitive cache (e.g., last category visited).
  • SessionStorage: temporary state like multi‑step wizards.
  • Cookie: authentication, analytics tracking (with consent).

Never use localStorage for critical data. An XSS attack exposes it all.

Web Workers: How to Bring Multi‑threading to JavaScript?

Web Workers allow executing code in a separate thread, leaving the main thread free for the UI. Perfect for heavy computations (image filters, compression, data processing). ES2024 introduces Atomics.waitAsync making synchronization between workers easier without blocking the thread.

Worker example for data processing

// main.js
const worker = new Worker('worker.js');
worker.postMessage({ data: hugeArray });
worker.onmessage = (e) => {
  console.log('Result:', e.data);
};

// worker.js
self.onmessage = (e) => {
  const processed = e.data.data.map(el => expensiveCalc(el));
  self.postMessage(processed);
};

Workers have no DOM access, but can use importScripts (or ES Modules with {type: 'module'}). If your app does client‑side analysis, use workers: you avoid page jank.

Sponsored Protocol

Which JavaScript Performance Techniques Actually Work?

Don't trust myths. We tested on real projects what truly reduces milliseconds:

  • Debounce and Throttle for frequent events (scroll, resize, input). They prevent executing logic dozens of times per second.
  • Avoid layout thrashing: don't read offsetHeight right after changing style; use requestAnimationFrame.
  • Code splitting with dynamic imports: load only what's needed.
  • Preconnect and prefetch for critical resources.
// Simple debounce
function debounce(fn, delay) {
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => fn(...args), delay);
  };
}

const onSearch = debounce((query) => fetchResults(query), 300);
input.addEventListener('input', (e) => onSearch(e.target.value));

We measure every intervention with Lighthouse and Performance API (performance.now()). If a technique doesn't reduce blocking time by at least 50ms, we discard it. Revenue doesn't wait.

What to Do Next

If you are developing or maintaining a JavaScript project, first upgrade your runtime (Node.js 22+, modern browsers). Then review your scripts: replace jQuery with native DOM, use ES Modules, apply async/await with strict error handling. Finally, measure: load your app with DevTools and look for Long Tasks in the Performance tab. Every millisecond gained is one less customer leaving. We, at Meteora Web, do this every day for our clients. And we can do it for you too.

Ing. Calogero Bono

> AUTHOR_EXTRACTED

Ing. Calogero Bono

Ingegnere Informatico, co-fondatore di Meteora Web. Esperto in architetture software, sicurezza informatica e sviluppo sistemi scalabili.
[ Read Full Dossier ]

> METEORA_WEB // DIGITAL AGENCY

We build the digital presence your business deserves.

Websites, social media, online advertising, e-commerce and high-performance hosting, engineered with method by computer engineers in Sciacca, for all of Italy.

> MW_JOURNAL

> READ_ALL()