This directory contains examples demonstrating how to use TONL in browser environments.
Basic JSON/TONL conversion with compression statistics.
- Convert JSON to TONL and back
- View compression savings
- Uses ESM bundle
Interactive TONLDocument API demonstration.
- Query operations (wildcards, filters, recursive)
- Modification operations (set, push, delete)
- Document statistics
- Uses ESM bundle
Full React application with TONL integration.
- User management CRUD operations
- Real-time TONL output
- Compression statistics
- Uses IIFE bundle with React 18
Vue 3 task manager application.
- Task CRUD with filtering
- Priority management
- Real-time TONL sync
- Uses IIFE bundle with Vue 3
-
First, build the browser bundles:
npm run build:browser
-
Serve the examples directory:
# Using Python python -m http.server 8000 # Using Node.js (npx) npx serve . # Using VS Code Live Server extension # Right-click on HTML file > Open with Live Server
-
Open in browser:
TONL provides three bundle formats for different use cases:
| Format | File | Size | Use Case |
|---|---|---|---|
| ESM | tonl.esm.js | ~6KB gzip | Modern browsers, bundlers |
| UMD | tonl.umd.js | ~5KB gzip | Webpack, RequireJS |
| IIFE | tonl.iife.js | ~5KB gzip | Direct script tag |
<!-- ESM via unpkg -->
<script type="module">
import { encodeTONL, decodeTONL } from 'https://unpkg.com/tonl/dist/browser/tonl.esm.js';
</script>
<!-- IIFE via unpkg -->
<script src="https://unpkg.com/tonl/dist/browser/tonl.iife.js"></script>
<script>
const { encodeTONL, decodeTONL } = TONL;
</script>See docs/BROWSER.md for complete API documentation.