Performance: Functions.php role
MEDIUM IMPACT
This affects the initial page load speed and server response time by controlling theme features and scripts loading.
<?php
// functions.php
function theme_enqueue_scripts() {
if (is_front_page()) {
wp_enqueue_script('custom-script');
wp_enqueue_style('custom-style');
}
}
add_action('wp_enqueue_scripts', 'theme_enqueue_scripts');
?><?php // functions.php wp_enqueue_script('jquery'); wp_enqueue_script('custom-script'); wp_enqueue_style('custom-style'); // No conditional loading or optimization ?>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unconditional script/style loading | Minimal | Multiple reflows if scripts manipulate DOM | High due to render-blocking CSS/JS | [X] Bad |
| Conditional and deferred loading | Minimal | Single reflow | Low paint cost due to fewer blocking assets | [OK] Good |