Overview
Milana Cap, a WordPress engineer at XWP and active community contributor from Serbia, highlighted two features changing how developers build interactive, performant WordPress sites: the Interactivity API and the HTML API. Both reduce reliance on bespoke JavaScript and bring more server-side capability back into everyday workflows.
About Milana
Milana works with enterprise clients at XWP, freelances via Toptal, contributes to WordPress documentation and plugin review, and speaks at conferences. She focuses on practical features developers can adopt today.
Why the Interactivity API matters
Before Gutenberg, PHP templates had global visibility across a page so different parts could interact naturally. Gutenberg’s block model made content componentized and isolated, so blocks couldn’t easily share state. That led to many ad-hoc JavaScript solutions that were inconsistent and hard to maintain.
The Interactivity API provides a core, standardized way for blocks to share data and respond to one another. Blocks can broadcast state and other blocks can consume it via a common API, enabling use cases like updating a cart count when a product button is clicked, syncing favorites across the UI, or keeping video playback persistent while navigating apparent page changes. Instead of full-page reloads, only the impacted parts re-render, giving a smoother, faster experience.
Concrete examples
– Movie demo: A Netflix-like demo shows favoriting updating counters, a trailer continuing to play in a minimized player across navigations, and near-instant page changes because only necessary pieces re-render.
– Core usage: Interactivity is already used in core features such as the paginated Query block and the image block’s lightbox.
– Common Ajax patterns: Pagination, lazy loading, and UI toggles can be implemented via Interactivity API to achieve no-full-reload behavior without custom JS frameworks.
Developer experience and adoption
Documentation exists and is improving. The main conceptual shift is deciding where to place interactive logic and how blocks should communicate: a single line in the right block can update many consumers. That makes placement and best practices important. The API is production-usable and shipping in Core, but it will continue to evolve; contributors can explore the Gutenberg repo and the Interactivity API showcase issue for examples and discussion.
Why the HTML API matters
The HTML API complements Interactivity by enabling server-side HTML processing so PHP can perform DOM-like transformations before outputting final HTML. It replaces brittle, client-side JavaScript or regex hacks with robust server-side manipulations.
Two primary tools
– Tag processor: Lets PHP modify attributes on block markup (add/remove classes, set accessibility attributes, change image or iframe attributes). It’s optimized and already used in production scenarios.
– HTML processor: More powerful and tag-structure aware — it can insert or remove nodes, wrap or unwrap elements, and alter inner content. It still needs further optimization for every edge case but is under active development.
Practical benefits
– Replace fragile JS tweaks: Common DOM tweaks (adding classes, annotating links) can be done server-side more reliably.
– Performance at scale: Reducing client-side JS work and extra requests saves milliseconds per request, which compounds into significant improvements for high-traffic sites.
– Cleaner, maintainable code: Server-side HTML handling follows standards and avoids the pitfalls of regex-based parsing.
Status and maturity
– Tag processor: Mature and already solving real problems (for example, removing nofollow on internal links via server-side rules).
– HTML processor: Capable but still being optimized for broader production usage.
– Interactivity API: Shipping in Core and usable today; will continue to grow with new scenarios.
When to use each
– Use Interactivity API when you need block-to-block communication or partial page updates without full reloads (favorites, cart counters, persistent media players, paginated queries).
– Use the HTML API for deterministic, server-side HTML transformations (attribute changes, element wrapping, node insertion/removal), especially when performance or avoiding client-side scripts matters.
Getting involved
Check the Gutenberg repository and the Interactivity API showcase issue for demos, examples, and community discussion. Experimenting with examples and thoughtfully placing logic across blocks will surface optimal patterns.
Final thoughts
Together, these APIs bring WordPress closer to modern interactive expectations while preserving server-side robustness. Interactivity restores page-wide awareness to componentized content, and the HTML API offers reliable server-side HTML manipulation. For developers—especially on enterprise projects—these tools simplify implementations, improve performance, and encourage consistent interactive behavior across themes and plugins.