A minimal, jQuery-compatible helper library for modern JavaScript projects
What is it?
microQuery.js is a lightweight JavaScript utility (~1KB gzipped) that mimics the most useful parts of jQuery โ
like $(), .on(), .addClass(), and $.ajax() โ without the overhead. Perfect for modern web apps that don't need the
full jQuery library.
$(fn)
).find()
, .children()
, .add()
, .index()
).addClass()
, .removeClass()
, .toggleClass()
).on()
).val()
).text()
, .html()
).attr()
, .prop()
, .data()
).css()
)$.ajax()
)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);
$('.btn').css('color', 'red');
$('#name').val('Jane');
let name = $('#name').val();
$.ajax({
url: '/api/data',
success: function (data) {
console.log(data);
}
});
$(function () {
$('.btn').on('click', function () {
$('.btn').toggleClass('highlight');
$.ajax({
url: '/api/data',
success: data => {
$('#output')[0].textContent = data.message;
}
});
});
});
MIT License โ (c) 2024โ2025 MyAppz.com
Not affiliated with the jQuery Foundation.