A minimal, jQuery-one-way-compatible helper library for modern JavaScript projects
microQuery.js is a tiny (~1KB gzipped) JavaScript utility that brings back the simplicity and convenience of jQuery’s $() syntax — for faster coding, cleaner code, and fewer keystrokes.
ℹ️ Note: code written for microQuery.js will run with jQuery.js. Not vice versa.
It covers just the essentials: DOM selection, events, class manipulation, content updates, and $.ajax() — all chainable, all modern, with none of jQuery’s overhead or legacy features.
microQuery doesn’t try to replicate jQuery — it simply offers a minimal set of helpers for the 95% of everyday DOM tasks, and leaves everything else to plain JavaScript.
- Small footprint
- Familiar API
- No dependencies
- Ideal for PHP/JS projects, static sites, or custom CMSes
- DOM ready shorthand (
$(fn)) - Core traversal and selection (
.find(),.children(),.siblings(),.add(),.index()`) - Class manipulation (
.addClass(),.removeClass(),.toggleClass()) - Event binding (
.on()) - Form value handling (
.val()) - Text and HTML helpers (
.text(),.html()) - Attributes and properties (
.attr(),.prop(),.data()) - Inline styles (
.css()) - Basic visibility (
.show(),.hide()) - DOM insertion (
.append(),.prepend()) - AJAX (
$.ajax())
microQuery keeps it minimal on purpose — if you need these, use jQuery or plain JS.
.click(),.focus(),.submit(), etc. (use.on("event", fn)instead).animate(),.fadeIn(),.slideUp()(use CSS transitions).closest(),.parents(),.next(),.prev()and other complex traversal.remove(),.empty()(useel.remove()orel.innerHTML = "")- Event namespaces,
.trigger(),.queue(), and plugins - Full jQuery compatibility — not the goal!
| Use case | Recommended Tool |
|---|---|
| Basic DOM manipulation with cleaner syntax | ✅ microQuery |
You just want $().on().addClass().html() |
✅ microQuery |
| You're using modern JS but want less typing | ✅ microQuery |
| You need jQuery plugins or advanced traversal | ❌ Use jQuery |
| You’re doing performance-critical, framework-level work | ❌ Use plain JS |
Include the script:
<script src="microQuery.min.js"></script>$(function () {
console.log('DOM is ready');
});$('.btn'); // by class
$('#output'); // by ID$('#container').find('.item').addClass('highlight');
$('#parent').children('.child').addClass('x');
$('.a').add($('#b')).addClass('highlight');$('.btn').on('click', function () {
alert('Clicked!');
});$('.btn').addClass('active');
$('.btn').removeClass('active');
$('.btn').toggleClass('active');$('#output').text('Hello');
$('#output').html('<strong>Hi</strong>');$('#link').attr('href', 'https://example.com');
$('#check').prop('checked', true);
$('#el').data('key', 'value');
const val = $('#el').data('key'); $('.btn').css('color', 'red');$('#name').val('Jane');
let name = $('#name').val();$.ajax({
url: '/api/data',
success: function (data) {
console.log(data);
}
});$('.btn')
.addClass('primary')
.text('Save')
.on('click', saveData);$('.item').each(function (el, i) {
console.log(i, el.textContent);
});$('.modal').css('display', 'none');
$('.btn').on('click', () => {
$('.modal').css('display', 'block');
});$('.btn, .link').addClass('interactive');// Example Usage
$(function () {
$('.btn').on('click', function () {
$('.btn').toggleClass('highlight');
$.ajax({
method: 'POST',
url: '/api/data',
data: { id: 123 },
success: data => {
$('#output').text(data.message);
}
});
});
});
We welcome pull requests and ideas! See CONTRIBUTING.md for guidelines.
MIT License — (c) 2024–2025 SirCode Not affiliated with the jQuery Foundation.