AlpineJS: The Modern Alternative to jQuery You Need to Try
If you’ve been around the web development block as long as I have, you’ve seen the rise and fall of countless frameworks. I’ve danced with jQuery, navigated the waters of Vue, ridden the React rollercoaster, and even tried my luck with Angular (we don’t talk about that). But in this ever-evolving landscape, there’s an under-the-radar tool that has been gaining serious traction, especially in the Laravel community with the TALL stack: AlpineJS. And let me tell you, it’s a game-changer, especially for those of us working with platforms like Shopify and WordPress.
A Blast from the Past: The jQuery Era
Remember the days when jQuery was the go-to for all things JavaScript? It was magical! You could manipulate the DOM, handle events, and create animations with a few lines of code. jQuery made JavaScript approachable and fun, turning complex tasks into simple, elegant code snippets. But as web development evolved, so did the need for more robust frameworks. Enter Vue, React, and Angular—powerhouses that took the world by storm, but often at the cost of simplicity.
Why AlpineJS is the Modern jQuery
Fast forward to today, and web development has come full circle. Server-side rendering is back in vogue, and there’s a growing demand for lightweight, easy-to-implement solutions. This is where AlpineJS shines.
AlpineJS is a minimal, lightweight JavaScript framework that gives you the power of React and Vue at a fraction of the complexity. Here’s why:
- Smaller Footprint: Alpine is about 19KB gzipped, jQuery about 26–29KB (see the size table below). The gap is smaller than people often claim, but in that smaller package Alpine gives you reactivity, state, and transitions, while jQuery gives you DOM helpers that modern browsers mostly ship natively.
- Simplicity: Just like jQuery, AlpineJS is easy to learn and quick to implement. You don’t need to set up a build process or deal with complex configurations. Just drop a script tag on your page, and you’re good to go.
- Reactive and Declarative: Alpine brings the reactivity of modern frameworks to your HTML. No need to learn a new language or syntax—just add a few x- attributes to your HTML, and you’ve got dynamic, reactive components.
- No Build Step Required: Unlike React or Vue, Alpine doesn’t require a complex build process. You can include it directly in your HTML and start building interactive components right away.
- Works Seamlessly with Existing Tech: Whether you’re working with a modern stack or maintaining a legacy site, AlpineJS fits right in. It’s especially well-suited for platforms like Shopify and WordPress, where you might not have the luxury of a full JavaScript framework.
I prefer AlpineJS because it gives you reactive state and declarative templates in a smaller package than jQuery, making it a leaner and more maintainable choice for modern web development.
Alpine.js vs jQuery: Bundle Size
Measured from the jsDelivr builds in October 2026:
| Library | Version | Minified | Gzipped |
|---|---|---|---|
| Alpine.js | 3.17.5 | 54 KB | ~19 KB |
| jQuery | 3.7.1 | 85 KB | ~29 KB |
| jQuery | 4.0.0 | 76 KB | ~26 KB |
| htmx | 2.0.11 | 50 KB | ~16 KB |
Gzipped size is what your visitors download, so that’s the column to compare. Alpine is roughly a third smaller than jQuery.
What about jQuery 4?
jQuery 4.0 shipped in January 2026, the first major release in almost a decade. It drops support for IE 10 and older, removes long-deprecated helpers like jQuery.trim, jQuery.isArray, and jQuery.type, moves the source to ES modules, and adds Trusted Types support. The result is about 3KB gzipped smaller than 3.x.
It’s a solid cleanup, and if you maintain a jQuery codebase, upgrading is worth it. But it doesn’t change how you write code: you still select elements, attach listeners, and update the DOM by hand. That imperative model is the real difference from Alpine, as the examples below show.
AlpineJs vs jQuery - Comparison
Let’s compare how AlpineJS and jQuery handle a common use case: toggling the visibility of a menu.
jQuery Example
$('#toggleButton').click(function () {
$('#menu').toggle();
});
Alpine Example
<div x-data="{ open: false }">
<button @click="open = !open" id="toggleButton">Toggle Menu</button>
<div x-show="open" id="menu" x-cloak>This is the menu content</div>
</div>
In this simple example, AlpineJS offers a more declarative approach, embedding the logic directly within the HTML. There’s no need to wait for the DOM to be ready or manually bind events—it’s all seamlessly integrated.
A More Complex UI: Slide-Out Cart
Here’s a more complex example: a slide-out cart UI.
AlpineJS Example
<div x-data="{visible: false}" x-cloak>
<button @click="visible = !visible">Toggle Cart</button>
<div
x-show="visible"
class="bg-opacity-50 fixed top-0 left-0 z-50 h-full w-full bg-black"
x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-out duration-300"
x-transition:leave-start="opacity-100 "
x-transition:leave-end="opacity-0"
></div>
<div
x-show="visible"
@click.outside="visible = false"
@keyup.escape.window="visible = false"
class="pointer-events-auto fixed top-0 right-0 z-50 h-dvh w-full max-w-lg"
x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="translate-x-full"
x-transition:enter-end="translate-x-0"
x-transition:leave="transition ease-out duration-300"
x-transition:leave-start="translate-x-0"
x-transition:leave-end="translate-x-full"
>
Hello Cart
</div>
</div>
In jQuery this would look like that:
<div id="cartContainer" class="relative">
<button id="toggleButton">Toggle Cart</button>
<!-- Background Overlay -->
<div
id="overlay"
class="bg-opacity-50 pointer-events-none fixed top-0 left-0 z-50 h-full w-full bg-black opacity-0 transition-opacity duration-300"
></div>
<!-- Cart Panel -->
<div
id="cartPanel"
class="pointer-events-auto fixed top-0 right-0 z-50 h-dvh w-full max-w-lg translate-x-full transform bg-white transition-transform duration-300"
>
Hello Cart
</div>
</div>
<script>
$(document).ready(function () {
let visible = false;
$('#toggleButton').click(function () {
visible = !visible;
toggleCart();
});
$('#overlay').click(function () {
visible = false;
toggleCart();
});
$(document).keyup(function (e) {
if (e.key === 'Escape') {
visible = false;
toggleCart();
}
});
function toggleCart() {
if (visible) {
$('#overlay')
.removeClass('opacity-0 pointer-events-none')
.addClass('opacity-100 pointer-events-auto');
$('#cartPanel').removeClass('translate-x-full').addClass('translate-x-0');
} else {
$('#overlay')
.removeClass('opacity-100 pointer-events-auto')
.addClass('opacity-0 pointer-events-none');
$('#cartPanel').removeClass('translate-x-0').addClass('translate-x-full');
}
}
});
</script>
Simplicity and Clean Code AlpineJS allows you to manage state (visible) and handle events directly within the HTML using attributes like x-show, @click, and @keyup.escape.window. This approach reduces the need for separate JavaScript code, resulting in cleaner and more maintainable code.
Transitions are built in With AlpineJS, transitions are handled declaratively using x-transition. You don’t have to manually toggle classes or write complex JavaScript logic to achieve the same effects. This makes your code more intuitive and easier to understand.
Event Handling AlpineJS simplifies event handling by allowing you to bind events like click and keyup.escape.window directly within the HTML, which is more straightforward than writing separate jQuery event listeners.
Automatic DOM Updates AlpineJS automatically updates the DOM when the state changes. In the jQuery version, you need to write functions to manually update the DOM, which adds more code and complexity.
Reduced Boilerplate With AlpineJS, there’s no need for additional setup or $(document).ready functions. You simply declare what you need in your HTML, making the code more concise.
Great choice for Laravel Blade and Shopify’s Liquid
Now, let’s talk about how AlpineJS plays nicely with templating engines like Liquid(used in Shopify) and Laravel Blade. These engines are all about rendering dynamic content on the server, and AlpineJS complements this by adding interactivity on the client side.
In a Shopify theme project, for example, you might use Liquid to render a product list server-side, then sprinkle some Alpine magic to add interactive elements like filters, modals, or dynamic content toggles. Because Alpine works directly in your HTML, there’s no need to overhaul your existing Liquid templates—just enhance them.
Similarly, in a Laravel project using Blade (like a modern WooCommerce Store), Alpine allows you to add reactive components directly within your Blade templates. Need a dropdown menu or a dynamic form? Alpine has you covered with a few simple attributes, keeping your Blade templates clean and maintainable.
Alternatives to Alpine.js
Alpine isn’t the only option for adding interactivity to server-rendered HTML. These are the ones worth a look:
- htmx: Instead of keeping state in the browser, htmx asks the server for HTML and swaps it into the page, using attributes like
hx-getandhx-target. A great fit when your backend already renders everything. It pairs well with Alpine: htmx for server round-trips, Alpine for local UI state. - Datastar: Combines the two ideas. Server-driven updates like htmx, plus reactive signals in
data-*attributes like Alpine. Newer and less battle-tested, but interesting if you want one library instead of two.
The Future is Alpine
In a world where web development is increasingly complex, AlpineJS offers a breath of fresh air. It’s lightweight, simple, and powerful enough to handle most of the interactivity you’ll need in modern web projects. Whether you’re working with an older tech stack or just want a simpler alternative to heavy frameworks, AlpineJS is a fantastic choice. It’s like jQuery for the modern era—familiar yet fresh, powerful yet lightweight.
So, next time you’re about to reach for jQuery or set up a complex React project for a simple site, give AlpineJS (or htmx) a try. You might just find they’re the tools you’ve been looking for all along.