microQuery.js

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.

Why use it?


๐Ÿ“ฆ Features


๐Ÿ”ง Usage

Include the script:

<script src="microQuery.min.js"></script>

๐Ÿงช Examples

DOM Ready

$(function () {
  console.log('DOM is ready');
});

Select Elements

$('.btn');         // by class
$('#output');      // by ID

Core traversal and selection

$('#container').find('.item').addClass('highlight');
$('#parent').children('.child').addClass('x'); 
$('.a').add($('#b')).addClass('highlight');

Event Listener

$('.btn').on('click', function () {
  alert('Clicked!');
});

Class Methods

$('.btn').addClass('active');
$('.btn').removeClass('active');
$('.btn').toggleClass('active');

Text & HTML

$('#output').text('Hello');
$('#output').html('<strong>Hi</strong>');

Attributes & Props

$('#link').attr('href', 'https://myappz.com');
$('#check').prop('checked', true);

CSS

$('.btn').css('color', 'red');

Form Values

$('#name').val('Jane');
let name = $('#name').val();

AJAX

$.ajax({
  url: '/api/data',
  success: function (data) {
    console.log(data);
  }
});

Example Usage

$(function () {
  $('.btn').on('click', function () {
    $('.btn').toggleClass('highlight');

    $.ajax({
      url: '/api/data',
      success: data => {
        $('#output')[0].textContent = data.message;
      }
    });
  });
});

๐Ÿ”’ License

MIT License โ€” (c) 2024โ€“2025 MyAppz.com
Not affiliated with the jQuery Foundation.

Download microQuery.js