Performance: Critical rendering path optimization
HIGH IMPACT
This affects how fast the main content appears on screen by optimizing the order and size of resources the browser loads first.
/* In functions.php */ function optimize_scripts() { wp_enqueue_style('critical-css', get_template_directory_uri() . '/critical.css', [], null); wp_enqueue_style('main-css', get_template_directory_uri() . '/style.css', [], null); wp_script_add_data('plugin-js', 'async', true); } add_action('wp_enqueue_scripts', 'optimize_scripts');
/* In header.php */ <link rel="stylesheet" href="style.css"> <script src="jquery.js"></script> <script src="plugin.js"></script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous loading of all CSS and JS in header | High (many nodes blocked) | Multiple reflows | High paint cost | [X] Bad |
| Inline critical CSS + async JS + deferred CSS | Low (minimal blocking nodes) | Single reflow | Low paint cost | [OK] Good |