decor/schedule

decor/schedule is a utility function that tries to run the given callback (the first argument) at the end of micro-task, which happens with IE11+ as well as latest Firefox/Chrome/Safari. For other browsers, notably ones not supporting MutationObserver, decor/schedule attempts to take the quickest way reasonably possible to run the given callback after micro-task ends.

decor/schedule returns a handle with .remove() method. If .remove() is called before the callback runs, running the callback will be cancelled.