Back Original

Show HN: µJS, a 5KB alternative to Htmx and Turbo with zero dependencies

Traditional websites reload the entire page on every click. µJS changes that: it intercepts link clicks and form submissions, fetches the new page in the background, and replaces only the content that changed. The browser never fully reloads — navigation feels instant, like a single-page application.

There's no framework to learn, no build step, no server-side changes. Add a single script tag to your existing site, call mu.init(), and every internal link becomes an AJAX navigation. It works with any backend — PHP, Python, Ruby, Go, or anything that serves HTML.

Features

Fast

Prefetch on hover, no full page reload, built-in progress bar. Navigations feel instant.

Lightweight

Single file, ~5 KB gzipped, zero dependencies. No build step required.

Drop-in

Works with any backend: PHP, Python, Ruby, Go, Node.js… No server changes needed.

Patch mode

Update multiple page fragments in a single request. Ideal for dashboards and complex layouts.

Triggers

Any element, any event. Live search, polling, focus actions — with built-in debounce.

HTTP verbs

GET, POST, PUT, PATCH, DELETE on links, buttons, and forms.

SSE

Real-time updates via Server-Sent Events. Combine with patch mode for multi-fragment streaming.

Modern

View Transitions API, DOM morphing via idiomorph, built on the Fetch API.

Quick start

<!-- 1. Include the script -->
<script src="https://unpkg.com/@digicreon/mujs@1.4.0/dist/mu.min.js"></script>

<!-- 2. Initialize -->
<script>mu.init();</script>

That's it. All internal links are now intercepted and loaded via AJAX.

How it works

1

Include the script

Add a single <script> tag to your page. No build tools, no bundler.

2

Links are intercepted

µJS listens for clicks on internal links and form submissions. External links are untouched.

3

Content is replaced

The page is fetched via AJAX, and only the targeted content is swapped — no full reload.