With Firefox 55 we saw the release of
Window.requestIdleCallback(callback), which makes it possible for a page to request that a script callback should be called as soon as the user agent is idle. This is something that Potch has written about1, but along with
requestIdleCallback there is also an underlying framework that enables the same or similar for both the UI as well as Gecko.
Starting a blog!