turbo-debug
v0.1.3
Published
Visualize and debug what Hotwire Turbo is doing - frame outlines, events, and more in a drop-in script.
Maintainers
Readme
turbo-debug
A lightweight JavaScript library to visually debug Turbo Frames on your web pages. It marks visible frames with a red dashed border and shows their id and src for quick inspection.
Features
- Highlights all visible
<turbo-frame>elements. - Shows frame
idandsrcusing a small overlay. - Automatically updates when frames are added, removed, or loaded dynamically.
- Non-intrusive: only sets
position: relativeon frames that are statically positioned. - Supports automatic enabling on page load.
Installation
Using npm
npm install turbo-debugUsing CDN
<script type="module" src="https://unpkg.com/[email protected]/dist/turbo-debug-auto.min.js"></script>This will automatically enable turbo-debug on page load. Replace x.y.z with the latest version found in the releases.
Usage
Manually Enable
import { enableTurboDebug } from 'turbo-debug';
// enable debugging on demand
enableTurboDebug();Automatic Enable (on page load)
import 'turbo-debug/auto';This will automatically enable turbo-debug once the DOM is ready.
API
enableTurboDebug()
Highlights all visible turbo frames and starts observing DOM changes and frame loads.
disableTurboDebug()
Removes highlights and stops observing changes.
Behavior
- Frames already positioned
absoluteorfixedwill not have their position overridden. - Observes the DOM using
MutationObserverand throttles updates to prevent performance issues. - Supports dynamic addition/removal of frames.
Development
Build
npm run buildThis generates both minified and unminified builds in the dist folder:
dist/turbo-debug.js– unminifieddist/turbo-debug.min.js– minifieddist/turbo-debug-auto.js– auto-enable variant
Tests
npm testWatch mode
npm run watchLicense
MIT © 2025 Ricardo van Hoepen
