Performance: Plugin header and activation
MEDIUM IMPACT
This affects the initial load time and responsiveness of the WordPress admin dashboard when plugins are activated or loaded.
<?php /* Plugin Name: Efficient Plugin Description: Minimal header and fast activation. Version: 1.0 */ register_activation_hook(__FILE__, function() { // Minimal setup, defer heavy tasks update_option('efficient_plugin_activated', true); // Schedule heavy tasks with wp_cron if (!wp_next_scheduled('efficient_plugin_deferred_task')) { wp_schedule_single_event(time() + 10, 'efficient_plugin_deferred_task'); } });
<?php /* Plugin Name: Heavy Plugin Description: Loads many resources and runs slow activation tasks. Version: 1.0 */ register_activation_hook(__FILE__, function() { // Heavy database queries and external API calls sleep(5); update_option('heavy_plugin_activated', true); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy activation hook with blocking tasks | Minimal DOM impact | 0 | 0 | [X] Bad |
| Light activation hook with deferred tasks | Minimal DOM impact | 0 | 0 | [OK] Good |