Asset Minification
CSS and JS assets are minified at build/release time. Minified files (.min.css, .min.js) ship in release packages but are not committed to git.
Standard
| What | Where |
|---|---|
| Source files | Committed to git (*.css, *.js) |
| Minified files | Generated at build time, gitignored (*.min.css, *.min.js) |
| Release ZIPs | Include both source and minified versions |
Universal Minifier
Location: moko-platform/build/minify.js
Auto-discovers all CSS/JS files in a source directory, skipping vendor/, node_modules/, and already-minified files.
| Tool | Purpose |
|---|---|
| clean-css | CSS minification (level 1) |
| Terser | JS minification (compress + mangle) |
# From any repo root
node path/to/moko-platform/build/minify.js src
# Or via Makefile
make minify
Makefile Integration
Every repo's Makefile includes a minify target:
MOKO_PLATFORM ?= $(or $(wildcard ../moko-platform),$(wildcard $(HOME)/moko-platform),$(wildcard /opt/moko-platform))
MINIFY_SCRIPT := $(MOKO_PLATFORM)/build/minify.js
.PHONY: minify
minify:
@if [ -f "$(MINIFY_SCRIPT)" ]; then \
node "$(MINIFY_SCRIPT)" $(SRC_DIR); \
elif [ -f "scripts/minify.js" ]; then \
node scripts/minify.js; \
fi
The build target depends on minify, so make build and make release both minify automatically.
CI/Release Integration
The auto-release.yml workflow includes Step 7.5 (Minify assets) before ZIP packaging:
- name: "Step 7.5: Minify assets"
run: |
npm install --no-save terser clean-css 2>/dev/null || true
MINIFY=""
for p in "../moko-platform/build/minify.js" "scripts/minify.js"; do
[ -f "$p" ] && MINIFY="$p" && break
done
[ -n "$MINIFY" ] && node "$MINIFY" src
MokoOnyx Runtime Minification
MokoOnyx includes MokoMinifyHelper which auto-minifies editable files on the server:
| Event | Behavior |
|---|---|
| Debug OFF | Regenerates .min files if source is newer than existing .min |
| Debug ON | Deletes all .min files so source is served directly |
| Install/Update | cleanMediaFolder() in script.php deletes stale .min files |
| File edit | Next page load detects stale .min and re-minifies |
Files managed by MokoMinifyHelper
| CSS | JS |
|---|---|
css/template.css |
js/template.js |
css/offline.css |
js/gtm.js |
css/editor.css |
js/user.js |
css/a11y-high-contrast.css |
|
css/user.css |
|
css/theme/light.standard.css |
|
css/theme/dark.standard.css |
|
css/theme/light.custom.css |
|
css/theme/dark.custom.css |
Joomla's Web Asset Manager auto-serves .min files when debug mode is off -- no separate asset registration needed.
.gitignore
All repos must include:
*.min.css
*.min.js
This is checked by the repo health check (check_repo_health.php).
Vendor Assets
Vendor libraries (e.g. Font Awesome) ship pre-minified only. Unminified vendor source files are not included in the repo or release packages. The cleanMediaFolder() script removes any stale unminified vendor files on install/update.
Related
- WIKI_STANDARDS -- repo file requirements
- WORKFLOW_STANDARDS -- CI/CD conventions
Repo: moko-platform · moko-platform wiki
| Field | Value |
|---|---|
| Minimum Version | 04.07.00 |
| Platform | joomla |
| Applies To | Joomla repositories |
| Revision | Date | Author | Description |
|---|---|---|---|
| 1.0 | 2026-05-09 | Moko Consulting | Initial minification standards |
| 2.0 | 2026-05-10 | Moko Consulting | Added MokoOnyx runtime minification, vendor policy, .gitignore requirement |