-
-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Hi :),
This is not a bug but rather a question on how to embed the script. We are using this only for import map support. For now, we have followed the embed instructions to use an async script. As all browsers now support it natively, we would prefer to load it conditionally (we're not saving a lot, I know, but we are selling themes and a lot of our users are running their stores on PageSpeed, and those non-technical merchants often ask us how to "optimize their store by removing scripts" ; we therefore try to load as little JS as possible to avoid support debt).
I tried the following approach which works on all the iOS versions I have tested:
<script>
if (!(HTMLScriptElement.supports && HTMLScriptElement.supports('importmap'))) {
import('URL-TO-POLYFILL');
}
</script>
However, I am not 100% sure about possible consequences or potential timing issue. Considering this polyfill architecture, would this be as safe as embedding it using the async way?
Thanks.