Make Alpine 3 support legacy browsers

Daniel Wentsch
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.

--

--

Daniel Wentsch
Daniel Wentsch

Written by Daniel Wentsch

I’m a freelance designer & developer from Freiburg, Germany. I write about capturing, collecting, and curating ideas—plus other things that spark my curiosity.

No responses yet