Complete documentation for all OCM Dimensions tools.
- Build CLI (
build-cli.js) - Size Calculator (
size-calc.js) - Browser UI
- NPM Scripts
- Configuration (
inscriptions.json) - Debug Mode
The cross-platform build tool for creating inscription-ready HTML files.
tools/build-cli.js
node tools/build-cli.js --workflow=<name> [options]| Workflow | Description | Input Directory |
|---|---|---|
threejs |
Three.js 3D graphics | tools/threejs/compressed-inputs/ |
p5js |
p5.js creative coding | tools/p5js/input/ |
compress-html |
Generic HTML compression | tools/compress-html/input/ |
| Option | Description | Example |
|---|---|---|
--workflow=<name> |
Required. Workflow to run | --workflow=threejs |
--base-url=<url> |
Base URL for local testing | --base-url=https://ordinals.com |
--output=<file> |
Custom output filename | --output=my-art.html |
--help |
Show help message | --help |
Build for inscription:
node tools/build-cli.js --workflow=threejs
# Creates: tools/threejs/index.htmlBuild for local testing:
node tools/build-cli.js --workflow=threejs --base-url=https://ordinals.com
# Creates: tools/threejs/index.local.htmlCustom output file:
node tools/build-cli.js --workflow=p5js --output=my-sketch.html
# Creates: my-sketch.htmlThe build CLI outputs:
- The built HTML file
- A size report with:
- Original code size
- Compressed (gzip) size
- Base64 encoded size
- Final HTML size
- Estimated inscription costs at various fee rates
============================================================
SIZE REPORT
============================================================
Original code size: 1.27 KB
Compressed (gzip): 642 B (50.7% reduction)
Base64 encoded: 856 B
Final HTML size: 2.22 KB
------------------------------------------------------------
ESTIMATED INSCRIPTION COSTS:
1 sat/vB 3,405 sats (0.00003405 BTC)
5 sat/vB 17,025 sats (0.00017025 BTC)
10 sat/vB 34,050 sats (0.00034050 BTC)
20 sat/vB 68,100 sats (0.00068100 BTC)
50 sat/vB 170,250 sats (0.00170250 BTC)
============================================================
Standalone tool for quick size estimates without a full build.
tools/size-calc.js
node tools/size-calc.js <file>
node tools/size-calc.js <file1> <file2> ...
node tools/size-calc.js --dir=<directory>| Option | Description | Example |
|---|---|---|
--dir=<path> |
Analyze all files in directory | --dir=src/ |
--json |
Output as JSON | --json |
--help |
Show help message | --help |
Single file:
node tools/size-calc.js my-sketch.jsMultiple files:
node tools/size-calc.js lib.js main.js utils.jsEntire directory:
node tools/size-calc.js --dir=tools/threejs/compressed-inputsJSON output (for scripting):
node tools/size-calc.js my-code.js --jsonHuman-readable output:
============================================================
FILE: my-sketch.js
============================================================
Original size: 1.02 KB
Compressed (gzip -9): 499 B (52.4% reduction)
Base64 encoded: 668 B
Estimated final HTML: 1.34 KB
Estimated inscription costs:
1 sat/vB 2,052 sats
5 sat/vB 10,260 sats
10 sat/vB 20,520 sats
20 sat/vB 41,040 sats
50 sat/vB 102,600 sats
JSON output:
{
"file": "my-sketch.js",
"original": 1045,
"compressed": 499,
"base64": 668,
"estimatedFinal": 1368,
"compressionRatio": "52.4",
"costs": [
{ "rate": 1, "rateStr": "1 sat/vB", "sats": 2052, "btc": "0.00002052" },
{ "rate": 5, "rateStr": "5 sat/vB", "sats": 10260, "btc": "0.00010260" }
]
}The tool uses color-coded indicators:
- Green (< 50 KB): Excellent - very affordable inscription
- Yellow (< 100 KB): Good - reasonable inscription cost
- Red (> 100 KB): Large - consider optimizing your code
A visual interface for compressing code without using the command line.
tools/browserUI/index.html
- Open
tools/browserUI/index.htmlin your web browser - Select the libraries you need (fflate is always included)
- Paste your code OR upload files
- See real-time size preview
- Click "Compress" to generate output
- Download the compressed HTML
As you type or paste code, you'll see:
- Original size
- Compressed size
- Base64 encoded size
- Estimated final HTML size
- Color-coded size indicator
- Estimated inscription costs
Choose which on-chain libraries to include:
- fflate (always included) - Compression/decompression
- p5.js - Creative coding library
- Three.js - 3D graphics library
- Paste Code: Directly paste JavaScript into the textarea
- Upload Files: Select one or more files to combine and compress
┌─────────────────────────────────────────────────────┐
│ Real-time Size Preview │
├─────────────────────────────────────────────────────┤
│ Original Size │ Compressed (gzip) │
│ 1.02 KB │ 499 B (52% smaller) │
├─────────────────────────────────────────────────────┤
│ Base64 Encoded │ Est. Final HTML │
│ 668 B │ 1.34 KB │
├─────────────────────────────────────────────────────┤
│ ✓ Excellent! Very affordable inscription size. │
├─────────────────────────────────────────────────────┤
│ Estimated Inscription Cost │
│ 1 sat/vB 2,052 sats │
│ 5 sat/vB 10.3K sats │
│ 10 sat/vB 20.5K sats │
│ 20 sat/vB 41.0K sats │
└─────────────────────────────────────────────────────┘
Convenient shortcuts defined in package.json.
| Script | Command | Description |
|---|---|---|
npm run build:threejs |
node tools/build-cli.js --workflow=threejs |
Build Three.js project |
npm run build:threejs:local |
...--base-url=https://ordinals.com |
Build for local testing |
npm run build:p5js |
node tools/build-cli.js --workflow=p5js |
Build p5.js project |
npm run build:p5js:local |
...--base-url=https://ordinals.com |
Build for local testing |
npm run build:compress-html |
node tools/build-cli.js --workflow=compress-html |
Compress HTML |
npm run build:compress-html:local |
...--base-url=https://ordinals.com |
Build for local testing |
npm run build:all |
Runs all build commands | Build everything |
npm run build:all:local |
Runs all local builds | Build all for testing |
| Script | Command | Description |
|---|---|---|
npm run size |
node tools/size-calc.js |
Run size calculator |
| Script | Command | Description |
|---|---|---|
npm test |
node --test tests/*.test.js |
Run all tests |
npm run test:build-cli |
Tests for build-cli.js | Test build CLI |
npm run test:size-calc |
Tests for size-calc.js | Test size calculator |
npm run test:templates |
Tests for templates | Test HTML templates |
npm run test:browser-ui |
Tests for browser UI | Test browser interface |
npm run test:integration |
End-to-end tests | Test full workflows |
npm run test:smoke |
./scripts/run-smoke-tests.sh |
Quick smoke tests |
Central configuration file for all inscription IDs and workflow settings.
tools/inscriptions.json
{
"inscriptions": {
"ocm-dimensions": {
"id": "2dbdf9eb...i0",
"name": "OCM Dimensions",
"description": "Parent inscription containing fflate and Three.js libraries",
"lines": {
"fflate": 28,
"threejs": 32
}
},
"fflate": {
"id": "6bac7ab4...i0",
"name": "fflate",
"description": "Standalone fflate compression library"
},
"p5js": {
"id": "255ce0c5...i0",
"name": "p5.js",
"description": "p5.js creative coding library"
}
},
"workflows": {
"threejs": {
"description": "Three.js 3D graphics workflow",
"requires": ["ocm-dimensions"],
"inputDir": "compressed-inputs",
"template": "page-structure.html"
}
},
"defaults": {
"baseUrl": "https://ordinals.com",
"contentPath": "/content/"
}
}| Name | Inscription ID | Contents |
|---|---|---|
| OCM Dimensions | 2dbdf9ebbec6be793fd16ae9b797c7cf968ab2427166aaf390b90b71778266abi0 |
fflate + Three.js |
| fflate | 6bac7ab4ce8d5d32f202c2e31bba2b5476a18275802b4e0595c708760f9f56b5i0 |
Compression library |
| p5.js | 255ce0c5a0d8aca39510da72e604ef8837519028827ba7b7f723b7489f3ec3a4i0 |
Creative coding library |
The OCM Dimensions inscription contains multiple libraries. They're extracted by line number:
- Line 28: fflate compression library
- Line 32: Three.js library (compressed)
All generated HTML files support debug mode for troubleshooting.
Add ?debug to the URL:
file:///path/to/index.local.html?debug
Or in a browser:
https://ordinals.com/content/<inscription-id>?debug
Open your browser's Developer Console (F12) to see:
[OCM] Fetching OCM Dimensions inscription...
[OCM] OCM Dimensions loaded, extracting libraries...
[OCM] fflate line: 28 , Three.js line: 32
[OCM] Decompressing user code...
[OCM] User code loaded successfully
| Message | Meaning |
|---|---|
Fetching OCM Dimensions inscription... |
Starting to load libraries |
OCM Dimensions loaded, extracting libraries... |
Successfully fetched, now parsing |
fflate line: X, Three.js line: Y |
Extracting specific lines |
Fetching p5.js library... |
Loading p5.js (p5js workflow only) |
Decompressing user code... |
About to decompress your code |
User code loaded successfully |
Your code is running! |
If something goes wrong, you'll see user-friendly errors:
Error loading inscription libraries. Check console for details.
The console will show the actual error:
[OCM] Failed to load libraries: Error: Fetch failed: 404
| Error | Cause | Solution |
|---|---|---|
Fetch failed: 404 |
Inscription not found | Check the inscription ID |
Decompression failed |
Corrupted data | Rebuild your project |
fflate is not defined |
Library not loaded | Check network/CORS |
Each workflow also supports the original Makefile approach.
cd tools/threejs
make clean && make| Target | Description |
|---|---|
make or make all |
Build everything |
make index.html |
Build inscription file |
make index.local.html |
Build local test file |
make src-compressed-string.base64 |
Compress input files |
make clean |
Remove generated files |
- On Unix/Mac systems with
makeinstalled - When you prefer the traditional approach
- For CI/CD pipelines that expect Makefiles
- On Windows (no
makerequired) - When you want size reports
- For cross-platform scripts
- When using npm scripts
Both approaches produce identical output.
# ═══════════════════════════════════════════════════════
# OCM DIMENSIONS - QUICK REFERENCE
# ═══════════════════════════════════════════════════════
# BUILD COMMANDS
npm run build:threejs # Build Three.js
npm run build:threejs:local # Build for local testing
npm run build:p5js # Build p5.js
npm run build:compress-html # Compress HTML
# SIZE CHECK
node tools/size-calc.js <file> # Check file size
node tools/size-calc.js --dir=src # Check directory
# TESTING
npm test # Run all tests
npm run test:smoke # Quick smoke test
# DEBUG
# Add ?debug to URL to see console logs
# FILES
# index.html → Inscribe this
# index.local.html → Test locally
# inscriptions.json → Central config
# ═══════════════════════════════════════════════════════