Wp Rocket Frontend Architecture
Developmentwp-rocket-frontend-architectureWp Rocket Frontend Architecture is an Agent Skill for development published in the wp-media/wp-rocket repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Use this skill when changing admin JavaScript, CSS, or HTML/Twig templates in WP Rocket.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/wp-media/wp-rocket/blob/HEAD/.claude/skills/wp-rocket-frontend-architecture/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/wp-rocket-frontend-architecture, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
WP Rocket — Frontend Architecture
Guidelines for JavaScript, CSS, and template changes in WP Rocket's admin UI.
Core principles
- No jQuery — use native DOM APIs only.
- No inline event handlers (
onclick,onchange, etc.) — useaddEventListener. - No unsafe
innerHTMLassignments — usetextContentorcreateElement/appendChild. - Use event delegation where appropriate (admin pages can load content dynamically).
Admin settings UI
- Settings page templates live in
views/. - JS for the settings page lives in
assets/js/. - Use
wp_localize_scriptto pass PHP data to JS — never inline<script>blocks with data. - Nonces must be localized — never hardcoded.
- New JS entry points must be registered and enqueued through a Subscriber.
AJAX / REST
- Use native
fetchwith the localized nonce for REST calls. - Use
wp.ajaxfor legacy AJAX (admin-ajax.php) if already present in the area. - Always handle errors explicitly — no silent failures.
Structural expectations
- JS files live under
assets/js/. - CSS files live under
assets/css/. - No new global variables — use module patterns or data attributes to share state.