Automatic AJAX navigation for links and forms
The "Boosted" pattern intercepts regular link clicks and form submissions,
converting them to AJAX requests. This provides SPA-like navigation without
rewriting your entire application.
Like htmx's hx-boost but using hyperscript behaviors!
boostedAJAX linkshtmx-likeSPA navigation
How it works: When you click a link inside a boosted container,
LokaScript intercepts the click, fetches the content via AJAX, swaps it into
the target area, and updates the URL. No page reload!
Demo 1: Manual Boosted Pattern
Click the navigation links - they load content without page reload:
Home Page
Welcome! This content was loaded via AJAX.
The URL updated but the page did not reload.
Demo 2: Boosted Form Submission
Form submission via AJAX with result display:
Enter a search term and submit
Boosted Behavior Features
Link Interception
Catches clicks on links and fetches via AJAX
Form Handling
Submits forms via AJAX (GET or POST)
History Management
Updates URL with pushState
View Transitions
Optional smooth CSS animations
Smart Detection
Skips external links, downloads, new tabs
Modifier Keys
Respects Ctrl/Cmd+click for new tab
The Code
Manual Boosted Pattern (Hyperscript):
<!-- Each link handles its own AJAX loading -->
<a href="/page"
_="on click
halt the event
add .hx-swapping to #content
fetch the @href of me as html
swap #content with it using view transition
push url the @href of me
remove .hx-swapping from #content">
Page Link
</a>
Boosted Form:
<form _="on submit
halt the event
set formData to new FormData(me)
set params to new URLSearchParams(formData)
fetch `/search?${params}` as html
swap #results with it
replace url `/search?${params}`">
<input name="q" />
<button type="submit">Search</button>
</form>
behavior Boosted(target, pushHistory)
initif no target then set target to document.body endif no pushHistory then set pushHistory to true endendon click from <a[href]/> in me
-- Skip if modifier keys pressedif event.metaKey or event.ctrlKey then exit endhalt the event
add .hx-swapping to target
fetch the @href of the target as html
swap target with it
remove .hx-swapping from target
if pushHistory then push url the @href of the target endendend
How it works:
Intercept link clicks with halt the event
Fetch content via AJAX using fetch
Swap into target using swap or morph
Update URL with push url
Smart detection skips external links and new tab clicks
htmx Comparison:
htmx
LokaScript
<body hx-boost="true">
Manual per-link or behavior pattern
Automatic link interception
Explicit control per link/form
When to use boosting:
Converting multi-page sites to SPA-like experience