Chaos Builder: V12 Orchestrator
The Chaos Builder is a zero-dependency, server-side DevOps pipeline engineered to provide
maximum JavaScript and CSS compression without relying on Node.js, Webpack, or native build tools.
🎯 High-Performance Minification
- Triple-Pass API: Combines Google Closure Compiler, Toptal API, and local Regex
scrubbing.
- Zero Dependency: Runs entirely on standard PHP with
curl logic.
- AST-Safe: Cloud APIs operate at the Abstract Syntax Tree level to prevent code breakage.
- V12 Auto-Discovery: Automatically detects source files via
-org naming convention.
- Alias Mapping: Displays human-readable codenames instead of real filenames for security.
- Persistent State: Maintains build logs directly in JSON.
70%
Max Compression
15+
Auto-Discovered
API
Cloud Accelerated
V12
Auto-Discovery
The "No Node.js" Philosophy
Traditional web development relies heavily on local environments (NPM, Webpack, Babel). The Chaos Builder was
created to allow on-the-fly deployments from any device. By offloading AST processing to
Google and Toptal, the server can compile complex 120,000+ byte JavaScript simulations into 60KB
production-ready assets without needing a local toolchain.
Key Features
- Auto-Discovery Engine: Scans the root directory for
*-org.js, *-org.css, and *.umd.js patterns to automatically build the asset list.
- Alias Mapping: All filenames are replaced with human-readable codenames (e.g. "Physics Engine Core" instead of
chaos-engine-core-org.js) to hide internal structure.
- Intelligent Fallbacks: If the Google API rate-limits, it falls back to Toptal. If
Toptal fails, it executes a local Regex scrub.
- SW Auto-Bump: After the final asset is processed, the Service Worker cache version is automatically incremented.
- Subfolder Resilient: Paths dynamically map to the true root directory ensuring parity
across test servers and live domains.
Architecture & V12 Auto-Discovery
The system was upgraded to V12 Auto-Discovery. Previous versions used hardcoded file arrays
and aggressive Regex golfing which occasionally corrupted syntax trees. V12 dynamically scans the filesystem
and uses Cloud APIs for AST-safe compilation.
The Triple-Pass Stack
Layer 1: Google Closure CLOUD API
The first pass sends code to closure-compiler.appspot.com. It reorganizes functions,
renames internal variables intelligently, and optimizes execution flow.
Layer 2: Toptal API CLOUD API
The second pass strips all semantic whitespace and compacts AST nodes via
toptal.com/developers, enforcing absolute minimal byte size.
Layer 3: Local Scrub NATIVE PHP
A final safety check that strips redundant semicolons and collapses lingering blocks locally,
ensuring production readiness even on API failures.
💡 AST over Regex: Abstract Syntax Tree (AST) compilation prevents minifiers from breaking
scoped variables. A traditional Regex minifier might delete a crucial space, but Google Closure explicitly
understands the JavaScript semantics.
AJAX Micro-Tasking
Processing 15+ modules in a single PHP request would trigger a 504 Gateway Timeout. The Chaos Builder splits the workload into sequential AJAX calls:
Processing Loop
# JS triggers sequential AJAX loop for all discovered assets
POST: chaos-builder.php (process=0, key=***) ➔ Awaits ➔ 200 OK
POST: chaos-builder.php (process=1, key=***) ➔ Awaits ➔ 200 OK
...
Each asset gets a dedicated TTL (Time-To-Live) with 8s API timeout.
Minification Pipeline
V12 auto-discovers Source-of-Truth files via the -org naming convention and maps them to their minified equivalents. The alias system hides real filenames from the UI.
| Alias (UI Name) |
Type |
Method |
| Physics Engine Core |
JS |
Triple-Pass (Closure + Toptal + Scrub) |
| Simulation UI Layer |
JS |
Triple-Pass |
| Interface Controller |
JS |
Triple-Pass |
| SPA Navigation Router |
JS |
Triple-Pass |
| Achievement Engine |
JS |
Triple-Pass |
| Atom Database |
JS |
Triple-Pass |
| Molecule Registry |
JS |
Triple-Pass |
| Chemistry Showcase |
JS |
Triple-Pass |
| Lightbox Engine (JS) |
UMD |
Triple-Pass (Pre-minified bypass) |
| Tab Navigator |
JS |
Triple-Pass |
| Service Worker Cache |
JS |
Triple-Pass + SW Auto-Bump |
| Event Driver |
JS |
Triple-Pass |
| Event System |
JS |
Triple-Pass |
| Global Stylesheet |
CSS |
Toptal + Scrub |
| Critical Path CSS |
CSS |
Toptal + Scrub |
| Lightbox Engine (CSS) |
CSS |
Toptal + Scrub |
💡 Auto-Discovery:
This table reflects the current alias map. New assets are automatically discovered when files matching the *-org.js or *-org.css pattern are added to the project root.
Persistence (build-stats.json)
The pipeline writes directly to a raw JSON array format, persisting previous build results so the interface
remains populated without needing database engines like MySQL.
Security Controls
⚠️ Access Restriction
The build script executes physical write actions on the server. To prevent malicious exhaustion or sabotage,
execution is locked behind an Action Key.
Authorization Flow
- Action Key: Execution requires the
BUILD_PASSWORD defined in server config.
- POST Verification: AJAX requests pass the key via POST body. An incorrect key
returns an immediate JSON error equivalent to HTTP 401.
- Index-Based Processing: File selection uses numeric indices into the auto-discovered array; users cannot
pass custom file paths, preventing Directory Traversal.
Native Execution (Standalone)
The UI is also available standalone. By navigating directly to the respective location for admin use, this
serves its own self-contained dark/light mode DOM interface. It shares no
html/body wrappers
with the primary site, ensuring iframe constraints and layout cascades never interfere.
Frequently Asked Questions
Why does the UI show "Fallback" in orange?
Both Google Closure and Toptal have rate limits or IP bans for abuse. If both cloud operations
timeout, the internal PHP script drops back to simple Regex regex optimizations. Your code is still
built, just slightly heavier.
Why doesn't Fancybox shrink?
Because fancybox-org.umd.js is fundamentally a vendor-shipped UMD file that is
already highly optimized. The API correctly detects no room for improvement.
I triggered a build but the site hasn't updated.
The assets compile securely, but the Service Worker (sw.min.js) and
footer.php need to coordinate a global cache bust. In extreme cases, a hard refresh
(Ctrl+F5) is required to purge Service Worker caches.
Can I add custom files?
Yes! V12 uses auto-discovery. Simply name your source file with the -org suffix
(e.g. my-module-org.js) and place it in the project root. The builder will
automatically detect it and map it to my-module.min.js. Add an alias in the
$ALIASES array for a human-readable UI name.