Does hiding an animated GIF with CSS conserve browser resources?

前端 未结 4 1268
庸人自扰
庸人自扰 2021-02-20 10:10

I have a gif image. It gets shown only on very specific events, not too often. By default, the gif\'s html tag is hidden using display: none

4条回答
  •  囚心锁ツ
    2021-02-20 11:03

    with display:none elements still exist in, and are resolved by the browser, they are only hidden from the user.

    you could use visible=false as this elements are not resolved in the browser but I don't know if you can use it.

    I would also check visibility: hidden as I don't know for this option how is it rendered.

    You can benchmark it the old school way, just jam up 50 (or more if necessary) gif's in your page, until your CPU spikes and than hide it and observe your CPU.

    I would also point out that the behavior will heavily depend on the browser itself so you would need to check it with different browser to be really sure.

提交回复
热议问题