Chaos Builder: V11 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: Operates at the Abstract Syntax Tree level to prevent code breakage.
- Asynchronous UI: File-by-file processing bypasses server timeout limitations.
- Persistent State: Maintains build logs directly in JSON.
70%
Max Compression
11
Core Modules
API
Cloud Accelerated
V11
Safe Mode
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
- Intelligent Fallbacks: If the Google API rate-limits, it falls back to Toptal. If
Toptal fails, it executes a local Regex scrub.
- Automated Cache Busting: Combined with an aggressive
?v=10.0.* flag system
to enforce immediate client updates.
- Subfolder Resilient: Paths dynamically map to the true root directory ensuring parity
across test servers and live domains.
Architecture & V11 Safe Mode
The system was recently upgraded to V11 Safe Mode. Previous versions used aggressive Regex
golfing which occasionally corrupted syntax trees (e.g. lgMass namespace collisions).
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
A legacy PHP script processing 11 heavy modules in one request would trigger a `504 Gateway Timeout` or `500
Server Timeout` within 10-30 seconds. Chaos Builder splits the workload:
Processing Loop
# JS triggers AJAX loop for totalFiles (11)
Fetch: build.php?process=0 ➔ Awaits ➔ 200 OK
Fetch: build.php?process=1 ➔ Awaits ➔ 200 OK
...
This ensures each module gets a dedicated TTL (Time-To-Live).
Minification Pipeline
The builder explicitly maps Source-of-Truth files (-org extensions) directly to their minified
equivalents, preventing infinite loops.
| Target Module |
Type |
Average Compression |
Method |
chaos-engine-core-org.js |
Simulation Physics |
~70.0% |
Triple-Pass |
chaos-events-complete.js |
Event Subsystem |
~45.0% |
Triple-Pass |
chaos-engine-ui-org.js |
Interface Handlers |
~38.0% |
Triple-Pass |
fancybox-org.umd.js |
Lightweight Library |
~0.0% |
Triple-Pass (Pre-minified bypass) |
style-org.css |
Global Design System |
~47.0% |
Toptal + Scrub |
sw.js |
Service Worker |
~63.0% |
Triple-Pass |
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 (currently manually
defined as laser in code).
- Parameter Verification: AJAX requests pass the key via URL parameters. An incorrect key
returns an immediate HTTP 401 Unauthorized equivalent.
- XHR Hardening: File inclusions and path mappings are hardcoded arrays; users cannot
pass custom `$_GET['file']` parameters preventing Directory Traversal.
Native Execution (Standalone)
The UI is completely standalone in build.php. By navigating directly to the file, it 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, by expanding the $filesToMinify associative array within build.php.
Make sure the target file has the -org suffix format so UI mask logic (anonymization)
works as intended.