fix(cls): add inline CSS to prevent navbar-collapse layout shift
Add CSS rule to hide navbar-collapse before Bootstrap JS loads. This prevents Bootstrap from calculating dimensions on an element that will be hidden anyway, eliminating 0.245 CLS on mobile. Target: reduce CLS from 0.479 to ~0.234 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
10
header.php
10
header.php
@@ -14,6 +14,16 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="<?php bloginfo('charset'); ?>">
|
<meta charset="<?php bloginfo('charset'); ?>">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<!-- CLS Prevention: Hide navbar-collapse before Bootstrap loads -->
|
||||||
|
<style id="cls-navbar-fix">
|
||||||
|
@media (max-width: 991.98px) {
|
||||||
|
.navbar-collapse:not(.show) {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<?php wp_head(); ?>
|
<?php wp_head(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user