Performance: Custom headers and footers
MEDIUM IMPACT
This affects the page load speed and visual stability by controlling how header and footer content is loaded and rendered.
<?php wp_enqueue_style('custom-header-style', get_template_directory_uri() . '/css/header.css'); ?> <?php wp_enqueue_script('custom-header-script', get_template_directory_uri() . '/js/header.js', [], null, true); ?> <?php get_header(); ?> <header> <h1>My Site</h1> </header> <?php get_footer(); ?>
<?php get_header(); ?> <!-- Inline styles and scripts inside header --> <header> <style>body {background: #fff;}</style> <script>console.log('header loaded');</script> <h1>My Site</h1> </header> <?php get_footer(); ?>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline styles/scripts in header/footer | Low DOM nodes | Multiple reflows due to blocking | High paint cost from layout shifts | [X] Bad |
| External CSS/JS enqueued properly | Low DOM nodes | Single reflow | Low paint cost with stable layout | [OK] Good |