Using `setTimeout` to speed up `window.onload`

A few days ago, Martín Borthiry contacted me with a question. He had been using the optimized asynchronous Google Analytics snippet for a while, and noticed an additional speed gain when wrapping it inside a setTimeout() with a delay of 0 milliseconds….


This content originally appeared on Mathias Bynens and was authored by Mathias

A few days ago, Martín Borthiry contacted me with a question. He had been using the optimized asynchronous Google Analytics snippet for a while, and noticed an additional speed gain when wrapping it inside a setTimeout() with a delay of 0 milliseconds. His tests made it pretty clear that this technique was indeed slightly faster, but Martín had no clue why.


This content originally appeared on Mathias Bynens and was authored by Mathias


Print Share Comment Cite Upload Translate Updates
APA

Mathias | Sciencx (2010-09-08T12:08:56+00:00) Using `setTimeout` to speed up `window.onload`. Retrieved from https://www.scien.cx/2010/09/08/using-settimeout-to-speed-up-window-onload/

MLA
" » Using `setTimeout` to speed up `window.onload`." Mathias | Sciencx - Wednesday September 8, 2010, https://www.scien.cx/2010/09/08/using-settimeout-to-speed-up-window-onload/
HARVARD
Mathias | Sciencx Wednesday September 8, 2010 » Using `setTimeout` to speed up `window.onload`., viewed ,<https://www.scien.cx/2010/09/08/using-settimeout-to-speed-up-window-onload/>
VANCOUVER
Mathias | Sciencx - » Using `setTimeout` to speed up `window.onload`. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2010/09/08/using-settimeout-to-speed-up-window-onload/
CHICAGO
" » Using `setTimeout` to speed up `window.onload`." Mathias | Sciencx - Accessed . https://www.scien.cx/2010/09/08/using-settimeout-to-speed-up-window-onload/
IEEE
" » Using `setTimeout` to speed up `window.onload`." Mathias | Sciencx [Online]. Available: https://www.scien.cx/2010/09/08/using-settimeout-to-speed-up-window-onload/. [Accessed: ]
rf:citation
» Using `setTimeout` to speed up `window.onload` | Mathias | Sciencx | https://www.scien.cx/2010/09/08/using-settimeout-to-speed-up-window-onload/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.