requestAnimationFrame and setInterval are affected when window is hidden
requestAnimationFrame and setInterval/recursive setTimeout are affected when the browser tab is hidden
When you run a program that uses requestAnimationFrame and switch to another tab so that you cannot see it, requestAnimationFrame stops.
Run the program below and switch to another browser tab, requestAnimationFrame will freeze completely and setInterval will fire every 1 second.
This shouldn't be a problem in single-player games, but in multiplayer games using node.js, it becomes a huge problem.
Are there any methods to allow graphics to run in the background?
globalThis objects, and communicate through messages
You'll really have to do some research yourself and get some hands-on experience though.
Some MDN URLS:
no, in fact multiplayer games most of them won't do anything about this, because it won't affect them!
the events will just not happen when you want them to, but they will still happen soon enough, just like irl!