Re: requestAnimationFrame behavior on display:none iframes

On Thu, Apr 11, 2013 at 2:45 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 4/10/13 6:32 PM, James Robinson wrote:
>>
>> 1.) Gmail loads up a large portion of its script in an iframe styled to
>> be 0x0.  While this iframe is not display:none, it's hidden for any
>> practical definition of hidden.
>
> That's not quite true.
>
> For example, it has a well-defined CSS viewport and hence can do media
> queries and selector matching and other CSS things, unlike a display:none
> iframe...

It seems to me that by making display:none iframes slow down the rate
of rAF callbacks we cover the common usecase of saving CPU and battery
by slowing down animations inside of iframes, while also enabling the
use case of allowing hidden iframes to animate parent iframes by doing
a little bit of extra work by using a 0x0 iframe rather than a
display:none one.

I.e. we're optimizing for the common use case, while also enabling the
not-as-common use case.

Note that I'm listing it as not-as-common here since the only use case
mentioned so far is using iframes to work around the blocking-script
issue, which we nowadays have better solutions for using the async
attribute. So we can expect websites to in the long term migrate
towards that solution.

/ Jonas

Received on Saturday, 13 April 2013 03:49:13 UTC