• Resolved kbowson

    (@kbowson)


    Hey guys! As a preface, our LCP content is a small (>20kbs) featured image.

    I am trying to understand the critical css loading and it’s affect on LCP. It seems like our page + the corresponding HTML / embedded Critical CSS loads first. Then some non-deferred JS (ex: lazy load)… and then the rest of our CSS… then the LCP featured image.

    Is this correct? Is there any way to have that image be prioritized?

    PS: Is there any way to selectively use your image-sprite code. Ex: I add the class “sprite” and it will convert that to a sprite image?

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    Typically there are two types of images that have bad LCP; lazy-loaded images and images that are CSS background-images.

    The solution for the first is excluding your hero-images from being lazyloaded (adding skip-lazy as CSS class is a good way), the solution for the 2nd is loading the background-image also like this

    
    <img src="https://your.url/yourbackground/image/path.jgp" style="display:none;" />

    which will ensure the image is loaded with higher priority.

    hope this helps,
    frank

    Thread Starter kbowson

    (@kbowson)

    hey frank,

    sorry should have provided more detail. I already added the exclusion from lazy load. The biggest thing to load, that seems to slow down the page load, is our css file. But I certainly could be wrong. Anyway you could take a look?

    https://www.mantelligence.com/fun-trivia-questions/

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    based on a quick webpagetest.org test (3G fast bandwidth + Galaxy S8 simulated) the image for which LCP is calculated is loaded as 4th resource, but (and that is HTTP/2 for you) it competes for bandwidth with some other resources:

    the AO’ed CSS is the first request (after the base HTML) but that already has priority “idle” (as it’s just a print CSS when being requested), but for reasons only browsers know (decide) is it loaded early anyhow. the logo is next up with priority “medium”, after that you have your “LCP-image” also with priority “medium” BUT in the HTTP/2 stream is reads it depends on the logo. I’m not deep enough into HTTP/2 to know why and how that can be changed I’m afraid. after that you have a font-file (the social warfare icons) which have “highest” priority, so it would be interesting to see if that font-file can somehow be loaded later?

    hope this somehow helps ..
    frank

    Thread Starter kbowson

    (@kbowson)

    this is super super helpful. great to know that the css is set to ‘idle’. I did not know that there was that priority selection!

    man… it is crazy to me that we have it coming in 4th, and it still takes so long to ‘fully’ load.

    Thanks frank!

    Thread Starter kbowson

    (@kbowson)

    I am 100% sure you know about this… but thought this was cool: https://developers.google.com/web/updates/2019/02/priority-hints

    Thread Starter kbowson

    (@kbowson)

    hey, sorry, just ran the webpagetest on a mobile device and it says the css is loading with ‘low’ priority. is there a way to set it to idle on mobile too? Or more aggressively defer it? or?

    https://www.webpagetest.org/result/201104_Di2J_756c0e2b6c33556b17594c3e02f3a3a0/1/details/

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    no, the priority is not something AO actively sets, it’s the browser that decides based on resource type (e.g. fonts have high priority) and other properties (e.g. css with medium print has lower priority).

    those priority hints could help, but afaik this is not available outside Chrome “origin trials” yet.

    Thread Starter kbowson

    (@kbowson)

    okay gotcha. I did turn off all google fonts in AO. Is there a way to make this more… aggresive (we are still loading Google fonts and some woff ones)

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    problem is the font mentioned is not a Google Font, but a local one (for the social warfare icons).

    Thread Starter kbowson

    (@kbowson)

    and no way to block those in AO, right?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    no, afraid not. disabling social warfare would help, but guess you don’t want to go there .. πŸ˜‰

    Thread Starter kbowson

    (@kbowson)

    hah no! okay, thank you frank!

    Thread Starter kbowson

    (@kbowson)

    Hey, I’m sorry… I feel like I am taking crazy pills. I have tried everything I can think of to expedite the loading of the LCP image (I have gone as far as changing themes, removing all plugins but AO (including the Social Warfare font), tested the unused CSS extension, etc.) and nothing seems to work. I guess I just don’t understand why in the webpagetest waterfall, it shows that our AOed CSS + JS are loading BEFORE page render. These (to me) seem to be the only real competitors for resources.

    How can this be (I have critical css set AND the ‘defer all render blocking js/jquery’ (in the critical css extension)? Is this that http2 thing you were talking about?

    View post on imgur.com

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Afraid this is browser territory; it’s the browser that decides which requests are issued at what point, taking into account what it finds in the HTML. the only thing I can think of is which _might_ help (a bit) is adding the image in the preload field on AO’s Extra tab maybe? Other then that I’m out of ideas really :-/

    Thread Starter kbowson

    (@kbowson)

    this is crazy making…

    … is there any way to make that variable or based on a css class or? (that image changes for every post)

Viewing 15 replies - 1 through 15 (of 20 total)

The topic ‘LCP + Critical CSS’ is closed to new replies.