W3C home > Mailing lists > Public > public-web-perf@w3.org > July 2011

Re: Efficient Script Yielding - First Editors Draft

From: Kyle Simpson <getify@gmail.com>
Date: Fri, 1 Jul 2011 07:49:56 -0500
Message-ID: <00E8FFA56F1A4E94B630E3E3703D1C9C@spartacus>
To: "webperf" <public-web-perf@w3.org>, "Jatinder Mann" <jmann@microsoft.com>
Another use-case for efficient script yielding that I wanted to bring up:

For CSS transitions, if you for instance have a transition that's supposed 
to run for 1sec that does an ease-in fade for the background-color change of 
an element, and you want it to go from red to blue, you'd think you could 
do:

elem.style.backgroundColor = "red";
elem.style.backgroundColor = "blue";

Unfortunately, this doesn't work because the style changes are batched 
together by the browser, so it goes right to blue, no transition. The only 
known workaround is:

elem.style.backgroundColor = "red";
setTimeout(function(){ elem.style.backgroundColor = "blue"; },0);

Seems like this is a good use case for script yielding as well.


--Kyle
Received on Friday, 1 July 2011 12:50:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:04:31 UTC