Performance: Action hooks
MEDIUM IMPACT
Action hooks affect how and when code runs during page load, impacting server response time and client rendering speed.
<?php add_action('wp_head', function() { echo '<script>console.log("test");</script>'; }); ?>
<?php add_action('wp_head', function() { for ($i=0; $i<1000; $i++) { echo '<script>console.log("test");</script>'; } }); ?>
| Pattern | Server Processing | HTML Size | Render Blocking | Verdict |
|---|---|---|---|---|
| Heavy hook with loops | High CPU usage | Large HTML output | Blocks >100ms | [X] Bad |
| Minimal hook output | Low CPU usage | Small HTML output | Blocks <10ms | [OK] Good |