Make Alpine 3 support legacy browsers
Jul 29, 2022
After The other day, I learned that AlpineJS 3.x uses queueMicrotask — and that that’s an API not supported on Firefox < 69 and Safari < 12.1 (see caniuse for full support information).
Luckily, this can easily be polyfilled:
if (typeof window.queueMicrotask !== "function") {
window.queueMicrotask = function (callback) {
Promise.resolve()
.then(callback)
.catch(e => setTimeout(() => { throw e; }));
};
}
Originally published at https://wentsch.me.