Performance: Block registration
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by controlling how blocks are added and rendered in the editor and frontend.
register_block_type('my-plugin/my-block', array('editor_script' => 'my-block-editor-script', 'render_callback' => 'my_block_render_callback')); function my_block_render_callback($attributes) { wp_enqueue_script('my-block-frontend-script'); wp_enqueue_style('my-block-style'); return '<div>Block content</div>'; }
register_block_type('my-plugin/my-block', array('editor_script' => 'my-block-editor-script')); wp_enqueue_script('my-block-frontend-script'); wp_enqueue_style('my-block-style');
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Register block with unconditional frontend assets | Minimal | 0 | High due to style recalculation | [X] Bad |
| Register block with conditional asset loading via render callback | Minimal | 0 | Low, only when block present | [OK] Good |