|
|
|
|
|
by capableweb
1616 days ago
|
|
Definitely seems like alfon's solution is faster/better, as it's more accurate when the game speeds up. However, it's also more resource intensive! getBoundingClientRect (used to at least, long time I go I did browser performance stuff) forces a new layout calculation each time it's called, which is one of the most expensive things you can do in the DOM, and can lead to jank in the website. Some more information here: https://developers.google.com/web/fundamentals/performance/r... Just adding this information for the ones who don't know and like to know more about browser performance :) |
|
EDIT: Looked down thread and basically saw a bunch of examples of just that!