Code Monkey home page Code Monkey logo

Comments (3)

tunetheweb avatar tunetheweb commented on June 19, 2024 2

This is a very interesting one! And I had to pull out some favours with some CSS colleagues to figure it out.

Apparently applying filter is one of the properties that creates a new stacking context so, as that's added and removed as you hover over it, that's causing a slight recalc in the CSS which technically causes a change in the pseudo elements position (even though there's no visible change to the user).

The easiest way to prevent this is to create that new stacking context in advance, by uncommenting one of the two properties below:

      .overlay-container {
        transition: filter 0.2s ease-in-out;
        /* filter: brightness(1); */
        /* will-change: filter; */

The first (filter: brightness(1);) sets the filter property even in unhovered state to the default of 1 so it has a filter value and knows therefore that it needs it's own stacking context for when you change this default later.

The second (will-change: filter;) explicitly tells the browser that it needs it's own stacking context as a filter is going to be changed later. It's probably the cleaner of these two options as doesn't require you to explicitly set a default value (that might interfere with other CSS you have).

Should Chrome count this as CSS when there is no user-visible change? No, it probably shouldn't. So feel free to raise a bug at crbug.com/new, however it's quite a minor one in this case (do let us know if you have a bigger example!) and it'll actually be ever so slightly more performant to do the solution above, so I imagine it won't be the biggest priority to look at this.

Oh and btw, on that note, Chrome-specific issues should be raised to crbug.com or to our web-vitals-feedback group, rather than here. This repo is specifically for the web-vitals.js library and this issue could have been repeated with a layout-shift performance observer even outside the library (though you may not have realised that!).

from web-vitals.

tunetheweb avatar tunetheweb commented on June 19, 2024 1

UPDATE: using the will-change property fixes the issue on our end as well 💯

Excellent! Great to hear.

from web-vitals.

Magellol avatar Magellol commented on June 19, 2024

UPDATE: using the will-change property fixes the issue on our end as well 💯


Thanks for looking into this and for the suggestions. I guess on our end, I still need to figure out why the numbers we're seeing are larger than the reproducible example I sent above but in the meantime, I'll apply your suggestion and move on.

Oh and btw, on that note, Chrome-specific issues should be raised to crbug.com rather than here, or to our web-vitals-feedback group. This repo is specifically for the web-vitals.js library and this issue could have been repeated with a layout-shift performance observer even outside the library (though you may not have realised that!).

That makes sense. I wasn't sure where the problem was, good to know for next time.

from web-vitals.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.