
Writing JavaScript That Still Works Without jQuery
Write small JavaScript behaviours that work without jQuery, covering selectors, classes, events, feature checks, fallbacks, and easier migration paths.
Articles from more than two decades of building, rebuilding, debugging, and leading web projects.

Write small JavaScript behaviours that work without jQuery, covering selectors, classes, events, feature checks, fallbacks, and easier migration paths.
closest() in Vanilla JavaScript and jQueryUse closest() for DOM traversal in jQuery and vanilla JavaScript, replacing manual parent walking in menus, click handlers, and interactive UI cleanly.

classList in JavaScript: add(), remove(), toggle(), and contains()Use classList in JavaScript for add(), remove(), toggle(), and contains(), with cleaner DOM state updates, validation examples, and className cautions.

Use jQuery as an enhancement layer whilst keeping links, forms, navigation, and core page content usable without JavaScript, late scripts, or plugin failure.

!important in CSSUnderstand why !important in CSS creates cascade, specificity, consistency, and maintenance problems, plus when an override may still be defensible.
Handle click events in JavaScript with onclick and addEventListener, including vanilla alternatives to jQuery, event targets, and common interaction patterns.

DOMContentLoaded vs. load in JavaScriptCompare DOMContentLoaded and load in JavaScript, including parsing, asset loading, script timing, selector failures, and when each event is useful.

querySelector Returns null in JavaScriptDebug querySelector returning null in JavaScript by checking selector syntax, DOM timing, missing elements, search scope, and querySelectorAll differences.
Check whether an element exists with jQuery or vanilla JavaScript before running DOM code, avoiding null errors and fragile client‑side behaviour.
Opening a new browser window programmatically on‑click is very simple to achieve with jQuery, and no more complex to achieve with vanilla JavaScript too!
A bug in the WebKit engine that only affects website Retina screen devices means that setting a zero‑blur filter in CSS isn't as easy as it should be.

Use links for navigation and buttons for actions, preserving native focus and keyboard behaviour before adding custom click handlers or ARIA roles.

Choose between textContent and innerHTML safely, handle Internet Explorer's innerText fallback, and know exactly when untrusted HTML needs sanitisation.

removeeventlistener() Needs the Same Function ReferenceUnderstand why removeEventListener needs the original callback reference, how anonymous functions differ, and what Internet Explorer required in 2010.