Over the weekend, David Gwyer announced a custom server-side render component for block plugins. The co-founder of WPGO Plugins primarily built his component to speed up the rendering process for dynamic blocks within his own plugins. However, he has now released this component for other block developers in the WordPress community.
Most blocks are static. Their output remains the same and has no need to change. However, some blocks are dynamic. Their output needs to change based on a variety of reasons, such as the context they are output in or other changes within the WordPress system. For example, the core Latest Posts block is dynamic because the posts that it displays change as new posts are written. If they were output as a static block, the end-user would need to update the block each time a new post was written. Therefore, dynamic blocks come in handy because they are rendered by the server in the editor and on the front end.
The problem with rendering from the server is that it can be slow, especially if the user is making several successive options changes to a particular block. With each change, the block must be re-rendered. The core experience with dynamic blocks has not been ideal.
Gwyer’s new component is available via GitHub. The project has little code, and its primary JavaScript file weighs in at just over 4kb (uncompressed). It introduces a new
component, which works similarly to WordPress’s existing
. Block developers should have little trouble switching to this version for a quick test.
He is currently using his component within the Flexible FAQs plugin. After running through a few tests, the plugin’s dynamic blocks feel much more responsive, almost to the point where there is little difference between it and a JavaScript-rendered static block.