Ensure polyfill won't throw errors on non-Fledge based browsers
Closed this issue · 4 comments
Publishers will need to safely use the polyfill on pages that see traffic from every browser, including those like Safari, Firefox, Brave, etc., that will not be participating in the Fledge trials or the Turtledove-style auctions/interest group tagging.
Create an example that can be loaded on any browser which doesn't throw any errors.
Browsers that support the
module
value for the type attribute ignore any script with anomodule
attribute. That enables you to use module scripts while also providing nomodule-marked fallback scripts for non-supporting browsers.
– https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#module_fallback
<script type="module" src="main.js"></script>
<script nomodule src="fallback.js"></script>
So we can provide a fallback but basically only browsers that support modules will be able to parse this and anyone that doesn't will be ignored.
Can you provide a modified version of my original example which would safely log "fledge unsupported on this browser" on something like Safari 10.0, but call runAdAuction on a supported version of Chrome?
<script type="module" src="main.js"></script>
<script nomodule>console.log("fledge is not supported on this browser")</script>
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you think this is in error, please reopen the issue and comment with next steps or what you would like to see happen.