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.
$(fn)
).find()
,
.children(),
.siblings(),
.add(),
.index()`).addClass()
, .removeClass()
, .toggleClass()
).on()
).val()
).text()
, .html()
).attr()
, .prop()
, .data()
).css()
).show()
, .hide()
).append()
, .prepend()
)$.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()
(use el.remove()
or el.innerHTML = ""
)
.trigger()
, .queue()
, and pluginsUse 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://myappz.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);
}
});
});
});
MIT License — (c) 2024–2025 MyAppz.com
Not affiliated with the jQuery Foundation.