You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although the es-modules-shims script recommends including it as async in their README, this can lead to bugs as on browsers that support executing type="module" scripts out of the box, the async script might not execute before the module, leading to the importShim function not being available: guybedford/es-module-shims#385
This can be mitigated by changing async to defer when including the shim -- deferred scripts go into the same queue as modules, thus it guarantees that the shim will be executed first, before the module.
The text was updated successfully, but these errors were encountered:
As explained in the linked issue, it actually only makes sense to do this if the script needs to rely on importShim (which is only when there are no static imports to trigger the polyfilling mechanism). In the general case async is better than defer, but still having an option to choose between async/defer would be nice to allow for this edge case
JanPokorny
changed the title
Include the shim script as defer instead of async
Add an option to include the shim script as defer instead of asyncAug 14, 2023
Although the
es-modules-shims
script recommends including it asasync
in their README, this can lead to bugs as on browsers that support executingtype="module"
scripts out of the box, theasync
script might not execute before the module, leading to theimportShim
function not being available: guybedford/es-module-shims#385This can be mitigated by changing
async
todefer
when including the shim -- deferred scripts go into the same queue as modules, thus it guarantees that the shim will be executed first, before the module.The text was updated successfully, but these errors were encountered: