New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve browser compatibility #165
Conversation
Thanks, I don't see any issue with landing this as the approach. Alternatively if we did need to conditionally do the write path in future, is there a way to determine if |
Thank you for your reply~ |
In addition, there is no error too.So, we can't use |
Ok thanks for confirming. I've merged with a comment, the next release should be next week. |
I was looking at my lighthouse scores today and found this note about the usage of document.write: Reading up on the details here, it seems like our use case here probably isn't a real performance concern since it doesn't involve any network requests that might block parsing for an unreasonable amount of time. However, the red lighthouse warning and the associated score impact might still affect SEO (?) and is going to be hard to explain away to non-technical stakeholders, and can very easily drive people away from using es-module-shims. I was wondering if maybe loading a blob URL in the iframe as Happy to experiment with this and send a PR if that sounds like a good plan. Though I might need help from @xxgjzftd to verify this works in the Weixin browser (caniuse doesn't seem to have any data on it? https://caniuse.com/?search=createObjectURL). |
@lewisl9029 I'd also have preferred if we could have avoided Such a test could be constructed without access to the weixin browser since it would just be positively verifying that srcdoc is applying in other browsers. Let me know if that sort of approach might make sense? A PR would be great if you would like to work on this. |
@guybedford from #165 (comment), it sounds like @xxgjzftd already tried something along those lines and couldn't distinguish between the Weixin Browser and others:
The comment describes a bunch of other "active" feature detection approaches he attempted with little success, and seems pretty exhaustive to be honest, and I don't have any other ideas to try off the top of my head along those lines. I was hoping we could maybe bypass the shakey Curious if you're aware of any reasons why src & createObjectURL might not work for this purpose? |
@xxgjzftd looks like the new fix was shipped in 1.3.3: https://github.com/guybedford/es-module-shims/releases/tag/1.3.3 When you have the chance, would you mind upgrading to 1.3.3 or later and verifying that this new version still works in Weixin browser? Thanks! |
some browser such as Weixin built-in browser don't support setting srcdoc property of iframe element.
so es-module-shims doesn't work well in this browser because the
featureDetectionPromise
never be resolved.and there are many user of the Weixin Official Accounts which use this browser.
and i think document.write has better compatibility.