Performance: Header and footer customization
MEDIUM IMPACT
This affects the page load speed and visual stability by controlling how header and footer elements are loaded and rendered.
<?php
function add_scripts_good() {
wp_enqueue_script('light-script', get_template_directory_uri() . '/js/light-script.js', [], null, true);
wp_enqueue_style('main-style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'add_scripts_good');
?><?php
function add_scripts_bad() {
echo '<script src="heavy-script.js"></script>';
echo '<style>body { font-family: Arial; }</style>';
}
add_action('wp_head', 'add_scripts_bad');
add_action('wp_footer', 'add_scripts_bad');
?>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline scripts/styles in header/footer | Moderate | Multiple reflows | High | [X] Bad |
| Enqueued scripts/styles properly | Low | Single reflow | Low | [OK] Good |
| Large unoptimized images | Low | Multiple reflows | High | [X] Bad |
| Optimized images with dimensions and lazy loading | Low | Single reflow | Low | [OK] Good |