If something isn’t working as expected, the first step is to enableDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/soyleninjs/swappit/llms.txt
Use this file to discover all available pages before exploring further.
log: true on your instance. Swappit’s colorized console output shows exactly what it is doing at each step — successful fetches, DOM updates, warnings about duplicate regions, and errors with their full messages.
Content is not updating
Content is not updating
The most common cause is a mismatch between the
data-[handle]-update attribute names on the source page and the target page, or a different handle string.Checklist:- The handle passed to
new Swappit('handle')must exactly match the prefix in your data attributes. data-app-update="content"on the source page requiresdata-app-update="content"(same name) on the target page.- Names are case-sensitive —
Content≠content.
Invalid URL errors in console
Invalid URL errors in console
Swappit only accepts relative URLs that begin with Check the
/ or ./. Any other format throws an error.href values of your links as well — the same rule applies to href attributes on elements with data-swappit-handle.Links don't intercept navigation
Links don't intercept navigation
Incorrect update order
Incorrect update order
If updated regions appear to render in the wrong sequence, use the Execution order: section2 → section1 → section3.
data-[handle]-update-order attribute with numeric values. Elements with this attribute are processed first (lowest to highest); elements without it are processed last."Handle already in use" error
"Handle already in use" error
Each To retrieve an existing instance instead of creating a new one:Alternatively, use the
handle string must be unique across all active instances. Passing the same handle to new Swappit() twice throws this error.<swappit-instance> custom element — it automatically calls reinit() if an instance with that handle already exists, instead of throwing.History / back-forward buttons don't work
History / back-forward buttons don't work
"Only one instance can control history" error
"Only one instance can control history" error
Only one Swappit instance may have both Fix: Give only one instance full history control. Other instances can use
updateUrl: true and enableHistory: true active at the same time. A second instance with the same combination throws this error.updateUrl: true (without enableHistory) if they need URL updates, or omit both options entirely.Preload not working
Preload not working
The
data-preload attribute (and the preload option) only recognize the exact string values "instant" and "hover". Any other value — including an empty string or a typo — is silently treated as no preload.Scripts not executing after swap
Scripts not executing after swap
Scripts inside swapped regions do not execute automatically — this is intentional. Use the static helper methods in the See the Script Handling guide for a full explanation.
update:after event to re-run them explicitly.Cache not refreshing
Cache not refreshing
By default, You can also set this per link in HTML:
update() serves the URL from cache if it has been fetched before. Pass false as the second argument to force a fresh download:Dynamically added links not configured
Dynamically added links not configured
Swappit starts a
MutationObserver automatically when an instance is created. Any <a data-swappit-handle="..."> element added to the DOM after initialization is detected and configured automatically — no manual wiring needed.If dynamic links still aren’t working, enable log: true to check for error messages and verify the script loaded correctly before the links were inserted.<swappit-instance> not creating an instance
<swappit-instance> not creating an instance
The Also make sure the
<swappit-instance> custom element requires a non-empty data-handle attribute. Without it, the element logs an error and does nothing.swappit.min.js script is loaded — the custom element is defined inside it.Events not firing
Events not firing
Verify the event name follows the exact format: Replace
swappit:[handle]:[event].app with your actual instance handle. All events are dispatched on window.