Cumulative layout shift question
-
Hello,
I’m not sure how to fix this, I’m using the option “inline and defer CSS” as a sitewide default for posts and it works well and causes no problems with CLS.
My homepage uses a different layout and so the same critical CSS doesn’t work for it.
And so I’ve put this code in the functions.php with the homepage critical CSS inside it.add_filter(‘autoptimize_filter_css_defer_inline’,’my_ao_css_defer_inline’,10,1);
function my_ao_css_defer_inline($inlined) {
if (is_front_page()) {
return “your-home-page-css-goes-here”; // overwrite default a-t-f CSS
} else {
return $inlined; // use default a-t-f CSS for all other types
}
}Now this works pretty well, except for an increase in CLS. I’ve noticed that if two codes are running simultaneously (one in autoptimize inline and defer, and the other in functions.php) then it causes an increase in CLS for the homepage. And as I’m not experienced, I have no idea how to fix this.
Thanks
- The topic ‘Cumulative layout shift question’ is closed to new replies.