Performance: Uninstall and cleanup hooks
MEDIUM IMPACT
This affects page load speed and backend performance by ensuring no leftover data or processes slow down the site after plugin removal.
<?php register_uninstall_hook(__FILE__, 'my_plugin_uninstall'); function my_plugin_uninstall() { delete_option('my_plugin_option'); global $wpdb; $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}my_plugin_table"); } ?>
<?php // No uninstall hook, data remains in database // Plugin deactivated but options and custom tables remain ?>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No uninstall cleanup | No change | 0 | 0 | [X] Bad |
| Proper uninstall hook cleanup | No change | 0 | 0 | [OK] Good |