microQuery.js

A minimal, jQuery-one-way-compatible helper library for modern JavaScript projects

What is it?

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.

Why use it?


📦 Features


🚫 Not Supported (Intentionally)

microQuery keeps it minimal on purpose — if you need these, use jQuery or plain JS.


📦 When to Use microQuery

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

🔧 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);

$('#el').data('key', 'value');         
const val = $('#el').data('key');  

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);
  }
});

Chaining

$('.btn')
  .addClass('primary')
  .text('Save')
  .on('click', saveData);

Iterate Over Elements

$('.item').each(function (el, i) {
  console.log(i, el.textContent);
});

Toggle Visibility (via CSS)

$('.modal').css('display', 'none');
$('.btn').on('click', () => {
  $('.modal').css('display', 'block');
});

Combine Selectors

$('.btn, .link').addClass('interactive');

Example Usage

// 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);
      }
    });
  });
});

Live Examples

🔒 License

MIT License — (c) 2024–2025 MyAppz.com
Not affiliated with the jQuery Foundation.

https://myappz.com/microquery/demo.html