Affecting setTimeout()/setInterval() are now deferred during page load

Published: | Categories: DOM, Networking

Description

Starting with Firefox 66, timers added with the window.setTimeout or window.setInterval method during page load will be given a low priority and deferred until an idle time is available or the loading is complete.

While this change aims at improving the performance of complex web applications like Google Docs, unexpected race conditions could occur if the initialization code is not designed properly. One regression on the Best Buy’s website has been reported and later fixed by themselves, which was likely due to a change in the resource access order, according to a Mozilla developer.

Remember that timers on the web are not so accurate. It may take longer than specified for various reasons, such as when the browser tab is in background.

Update: Firefox 68 has made a similar change to XHR final events.

Update 2: Firefox 69 has made a similar change to fetch() as well.

References