Using requestIdleCallback  |  Web  |  Google Developers

requestIdleCallback is new performance API for scheduling work when the browser is idle.