JavaScript evolves faster than almost any other technology. What was the “right way” in 2018 is considered outdated today. Here’s where JavaScript stands in 2026 and what you actually need to know.
What to Stop Using Immediately
jQuery (for new projects) jQuery was essential when browsers were inconsistent. Today, every browser implements the same standard APIs. The things jQuery did in 2010 are now one or two lines of vanilla JS:
// jQuery (old)
$('.menu').addClass('active');
$('.btn').on('click', handler);
$.ajax({ url: '/api', success: callback });
// Modern vanilla JS (2026)
document.querySelector('.menu').classList.add('active');
document.querySelector('.btn').addEventListener('click', handler);
const data = await fetch('/api').then(r => r.json());
jQuery adds ~87KB to your page. For new projects, there is no reason to include it. var declarations var is function-scoped and hoisted in confusing ways. Use const and let exclusively:
// Avoid
var count = 0;
var userName = getUserName();
// Use
const userName = getUserName(); // never reassigned
let count = 0; // may be reassigned
Callback pyramids
// Avoid (callback hell)
getData(function(data) {
processData(data, function(result) {
saveResult(result, function(saved) {
console.log('done');
});
});
});
// Use async/await
const data = await getData();
const result = await processData(data);
await saveResult(result);
Modern ES2024+ Features You Should Be Using
Optional Chaining (?.) and Nullish Coalescing (??)
// Without optional chaining (old)
const city = user && user.address && user.address.city;
// With optional chaining (modern)
const city = user?.address?.city;
// Nullish coalescing (use default if null/undefined, but not if 0 or '')
const name = user.name ?? 'Anonymous';
const count = user.count ?? 0;
Array methods: map, filter, reduce, find
const services = [
{ name: 'Web Dev', active: true, price: 50000 },
{ name: 'Mobile', active: false, price: 80000 },
{ name: 'SEO', active: true, price: 15000 },
];
// Get only active services
const active = services.filter(s => s.active);
// Get all names
const names = services.map(s => s.name);
// Find the cheapest
const cheapest = services.reduce((min, s) => s.price < min.price ? s : min);
// Find by condition
const seo = services.find(s => s.name === 'SEO');
Destructuring and Spread Operator
// Object destructuring
const { name, email, phone = 'Not provided' } = user;
// Array destructuring
const [first, second, ...rest] = items;
// Spread — merge objects
const updatedUser = { ...user, lastSeen: new Date() };
// Spread — merge arrays
const allServices = [...webServices, ...mobileServices];
Template Literals
// Old string concatenation
const message = 'Hello ' + name + ', your order #' + orderId + ' is ready.';
// Template literal
const message = `Hello ${name}, your order #${orderId} is ready.`;
// Multi-line strings
const html = `
<div class="card">
<h2>${title}</h2>
<p>${description}</p>
</div>
`;
Structuring JavaScript in PHP Projects
For PHP sites that don’t use React or Vue, here’s the pattern we use at Softcrony:
// app.js — one file, well-organised modules
// ── Navigation module ─────────────────────
const Nav = {
init() {
this.menuBtn = document.querySelector('[data-menu-toggle]');
this.menu = document.querySelector('[data-mobile-menu]');
if (this.menuBtn) this.menuBtn.addEventListener('click', () => this.toggle());
},
toggle() {
const isOpen = this.menu.getAttribute('aria-hidden') === 'false';
this.menu.setAttribute('aria-hidden', String(isOpen));
this.menuBtn.setAttribute('aria-expanded', String(!isOpen));
}
};
// ── Contact form module ───────────────────
const ContactForm = {
init() {
const form = document.querySelector('[data-contact-form]');
if (!form) return;
form.addEventListener('submit', (e) => this.validate(e, form));
},
validate(e, form) {
const email = form.querySelector('[name="email"]').value;
if (!email.includes('@')) {
e.preventDefault();
alert('Please enter a valid email address.');
}
}
};
// ── Scroll animations ─────────────────────
const Animations = {
init() {
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('is-visible');
}
});
}, { threshold: 0.15 });
document.querySelectorAll('.animate-on-scroll').forEach(el => observer.observe(el));
}
};
// ── Initialise everything ─────────────────
document.addEventListener('DOMContentLoaded', () => {
Nav.init();
ContactForm.init();
Animations.init();
});
Fetch API: Replacing AJAX in 2026
// Modern API call pattern
async function submitForm(formData) {
try {
const response = await fetch('/api/contact/', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(Object.fromEntries(formData))
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
showSuccessMessage(result.message);
} catch (error) {
console.error('Submit failed:', error);
showErrorMessage('Something went wrong. Please try again.');
}
}
Do You Need React or Vue for Your Project?
Honestly? Probably not. React and Vue are excellent for complex, highly interactive applications — dashboards, real-time feeds, complex forms with dozens of interdependent states. For a marketing site, a service company website, an e-commerce store, or a blog: vanilla JS with modern ES2024 features is simpler, faster, and easier to maintain. No build step, no node_modules, no framework updates to manage. Our rule of thumb: if you’re building something that could be a native mobile app, use React. If you’re building a website that happens to have some interactivity, use vanilla JS.
The 2026 JavaScript Checklist
- ☐ No jQuery in new projects
- ☐ const and let only (no var)
- ☐ async/await for all asynchronous operations
- ☐ Optional chaining and nullish coalescing
- ☐ Template literals instead of string concatenation
- ☐ Fetch API instead of XMLHttpRequest
- ☐ Modules with import/export (or organised object pattern for PHP projects)
- ☐ Always handle errors in async functions
- ☐ prefers-reduced-motion check for all animations
— Building a web application and not sure how to structure your frontend? Our development team has delivered projects across India using modern JavaScript patterns. Get in touch →
Leave a comment