Hi @bracas,
You don’t have to use !important
, I only gave that as one of the options that everyone could use and I explained why it’s there (part of browser standard). And you can do some trial and error to create the final and working combinations of selectors and ID just to make it work instead of using !important
like what you already did.
Yes, you could use any ID, there is no limitation for creating and using CSS selectors as long as you’re targeting the correct element. And you could always use browser developer tools to help you composed proper CSS.
The child theme is less prioritized because it’s loaded first, the last will always override the first. That code will not override the parent, the parent theme doesn’t use style.css. That code will only put the child theme’s style.css to the end of wp_head
to make it the last.
About FUOC, the stylesheet is a file that browser needs to download. Let me explain with a similar example when you load your page, do the images rendered instantly? It’s not, since the browser will download it first and the download time depends on the cache, internet speed, rendering speed, device’s processing capacity. And once downloaded, the browser will render it. That same goes to any files and stylesheet is included. It’s not theme related, that’s why I suggested using pre-loader to prevent FUOC. And FUOC is more noticeable if you have optimization related to defer and async. Please check this https://kinsta.com/blog/eliminate-render-blocking-javascript-css/
While this should have eliminated all rendering-blocking CSS, enabling this option produced the dreaded FOUC, so I did not leave this option enabled.
Because Asynchronous loading means the browser will not wait for the stylesheet and it will render the unstyled content instantly,
And there is no rule that there should be no inline CSS. In fact, Google and other modern websites use inline CSS. It’s much faster since the CSS is downloaded in one go along with page content. The one with the problem with inline CSS is internet with slow connections. And please check this https://gomakethings.com/inlining-critical-css-for-better-web-performance/
And about the traffic, a 2kb inline CSS moved to stylesheet doesn’t mean it has less 2kb traffic. The bandwidth and payload size is still the same, it’s just moved to a different location (unless there is caching). Inline CSS is good for the dynamic setup that usually changes, while stylesheet is good for permanent or static CSS.
I recommend contacting a developer for the optimization of your site, as there are many things to consider to properly implement your desired setup. It’s not just about the theme, it’s the entirety of Wordpress since it’s modular. But yes, I recommend using pre-loader as I mentioned before as workaround for FOUC, but pre-loader may not even work if you have Async optimization too. Hence, optimizing another may lead to another optimization issue.
Thanks!