JavaScript without jQuery
Moving away from jQuery improves performance, reduces bundle size, and aligns with the modern web platform. Native DOM APIs and polyfills now cover most common needs.
Canceling event propagation
Event propagation can be stopped in different ways, with distinct effects on default actions, bubbling, and handlers on the same element. jQuery’s return false combines prevention and propagation stop.
Events triggered by jQuery cannot be observed by native event listeners
jQuery trigger() emits events that native addEventListener() handlers cannot observe, which breaks mixed jQuery and non-jQuery code. Native dispatchEvent() works for both worlds.
Event delegation (without jQuery)
Single-listener event handling can cut setup cost and support dynamically added elements, but it can slow fast events and limits bubbling control.
Select2 alternatives without jQuery
jQuery-free dropdown components for advanced selects are needed when Select2 is too dependent on jQuery or missing features.
How to avoid multiple versions of a package in yarn
Duplicate package versions in Yarn can break shared globals like window.jQuery, leaving plugins such as datepicker unavailable. resolutions can force one version across dependencies.
jQuery and cross domain AJAX requests
Cross-domain AJAX requests with jQuery suppress X-Requested-With and CSRF headers for security, so servers may not recognize them as AJAX. A prefilter can re-enable headers for trusted hosts.
Capybara: Find the innermost DOM element that contains a given string
Finding a matching text node in nested DOM trees is tricky because broad text queries return ancestor elements too. Selecting the deepest element avoids false matches in Capybara, XPath, and jQuery.
Cheat Sheet for the modern DOM API
Quick reference for native DOM methods and properties that replace many jQuery calls, helping you find equivalents without browsing Element interfaces.
jQuery: Work with text nodes and comment nodes
contents() returns all child nodes, including text and comment nodes, and filter() can isolate non-element nodes by nodeType.
jquery-timing - a jQuery plugin you should know about
Chainable timing helpers reduce nested callbacks in jQuery and keep animation and timeout code readable.
DOM API for jQuery users
Quick reference for replacing common jQuery DOM tasks with native browser APIs and handling event delegation gaps without jQuery.
Guideline for moving from jQuery to vanilla JavaScript
Practical equivalents for common jQuery patterns in vanilla JavaScript, useful when modern browser support makes dependency-free code feasible.
Use jQuery's selector engine on vanilla DOM nodes
Use Sizzle via $.find to select descendants from plain DOM nodes when jQuery collections are unavailable, too slow, or awkward for whole-document work.
Check whether an element is visible or hidden with Javascript
Visibility checks can differ between DOM APIs and libraries, causing elements to be misclassified as shown or hidden. jQuery, jQuery 3, and Prototype use different rules.
Webpacker: Side effects of using window.* within the ProvidePlugin
Using window.jQuery in ProvidePlugin can leave jQuery undefined in the browser while $ still works; assigning through global avoids the conflict.
Compare two jQuery objects for equality
jQuery creates a new wrapper on each $(...) call, so == fails for matching selections. Use .is() to test whether two jQuery objects wrap the same DOM elements.
jQuery promises: done() and then() are not the same
jQuery done() and then() differ in promise chaining: then() waits for returned promises, while done() ignores them and can resolve too early.
Traversing the DOM tree with jQuery
jQuery traversal methods move a selection through the DOM tree to find descendants, ancestors, parents, children, or matching elements efficiently.
Sticky table header with jQuery
Keep table headings visible while scrolling large tables by cloning the header and syncing widths and horizontal position with jQuery.
Unobtrusive jQuery to toggle visibility with selects and checkboxes
jQuery can show or hide form sections based on select values, radio buttons, checkboxes, blank values, and _checked or _unchecked states.
jQuery: How to replace DOM nodes with their contents
Remove selected HTML tags while preserving their inner text and other child nodes using contents() and unwrap() in jQuery.
jQuery: How to attach an event handler only once
Prevent duplicate event callbacks in jQuery by using .one() for single-fire handlers or off()/on() with the same function reference.
Make jQuery.animate run smoother with almost no code changes
jQuery .animate() can feel choppy because it relies on JavaScript timers, while CSS transitions deliver smoother motion with nearly the same API.