+0
Daily
-6
Weekly
-13
Monthly
20,106
stars
1,700
forks
509
watchers
207
prs
73
issues
2
releases
README
You (Might) Don't Need jQuery
Frontend environments evolve rapidly nowadays and modern browsers have already implemented a great deal of DOM/BOM APIs which are good enough for production use. We don't have to learn jQuery from scratch for DOM manipulation or event handling. In the meantime, thanks to the spread of frontend libraries such as React, Angular and Vue, manipulating the DOM directly becomes anti-pattern, so that jQuery usage has never been less important. This project summarizes most of the alternatives in native JavaScript implementation to jQuery methods.
Snippets target current evergreen browsers (Chrome, Edge, Firefox, Safari). Internet Explorer is no longer supported by Microsoft, so IE-specific fallbacks have been removed. If you still need them, see the last IE-compatible version.
ℹ️ Notice:
1. jQuery is still a great library and has many valid use cases. Don’t migrate away if you don’t want to!
2. The alternatives are not completely equivalent in all scenarios, and it is recommended that you test it before using it.
Table of Contents
1. Translations
1. Query Selector
1. CSS & Style
1. DOM Manipulation
1. Ajax
1. Events
1. Utilities
1. Promises
1. Animation
1. Alternatives
1. Browser Support
Translations
한국어
正體中文
简体中文
Bahasa Melayu
Bahasa Indonesia
Português(PT-BR)
Tiếng Việt Nam
Español
Русский
Кыргызча
Türkçe
Italiano
Français
日本語
Polski
Query Selector
In place of common selectors like class, id or attribute we can use document.querySelector or document.querySelectorAll for substitution. The differences lie in:
document.querySelector returns the first matched element
document.querySelectorAll returns all matched elements as a static NodeList. It supports forEach, and can be converted to Array using Array.from(document.querySelectorAll(selector)) or any of the methods outlined in makeArray
If there are no elements matched, jQuery returns an empty jQuery object and document.querySelectorAll returns an empty NodeList, whereas document.querySelector returns null.
Notice: document.getElementById, document.getElementsByClassName and document.getElementsByTagName are slightly faster than querySelector, but getElementsBy return a live HTMLCollection that changes as the DOM changes. Prefer querySelector unless you have measured a bottleneck.
- 1.0 Query by selector
js
// jQuery
$('selector');
// Native
document.querySelectorAll('selector');
- 1.1 Query by class
js
// jQuery
$('.class');
// Native
document.querySelectorAll('.class');
// or
document.getElementsByClassName('class');
- 1.2 Query by id
js
// jQuery
$('id');
// Native
document.querySelector('id');
// or
document.getElementById('id');
- 1.3 Query by attribute
js
// jQuery
$('a[target=_blank]');
// Native
document.querySelectorAll('a[target=_blank]');
- 1.4 Query in descendants
js
// jQuery
$el.find('li');
// Native
el.querySelectorAll('li');
- 1.5 Top issues
Latest release
Release 3.0 v3.0 2026-11-06The guide now targets evergreen browsers. Every snippet that was changed is checked against jQuery 4 by a test. Breaking: Internet Explorer is no longer supported Snippets target the latest Chrome, Edge, Firefox, Safari and Opera. IE-specific fallbacks are gone: vendor-prefixed matchesSelector, the closest polyfill, Array.prototype..call, createEvent / initCustomEvent, pageYOffset, parentNode.removeChild. If you still need IE, use the last IE-compatible version or v2.0. Native one-liners | jQuery | Native | |---|---| | remove / insertBefore / insertAfter | el.remove() / el.before() / el.