const supportPromise = typeof Promise === 'function' const supportMutationObserver = typeof MutationObserver ==='function' function addToMicroTasking(fn) { if (supportPromise) { return Promise.resolve(fn) }else if (supportMutationObserver) { const mutationObserver = new MutationObserver(fn) const text = document.createTextNode('0') mutationObserver.observe(text, { characterData: true }) text.data = '1' } else{ setTimeout(fn, 100) } }