The documentation for @babel/polyfill has the following note:
If you are looking for something that won't modify globals to be used in a tool/library, checkout the transform-runtime plugin.
On the transform-runtime documentation, it says the following:
While this [@babel/polyfill usage] might be ok for an app or a command line tool, it becomes a problem if your code is a library which you intend to publish for others to use or if you can't exactly control the environment in which your code will run.
More generally speaking, a lot of articles explaining the use of polyfills say that you may want to use a different solution if you care about polluting the global namespace.
In my understanding, most polyfills are loaded conditionally. If an implementation already exists, the polyfill will not overwrite it. My question is: under what kind of circumstances can polyfills in an external script cause an existing website to break? The only reason that I have been able to find so far is that the external script might load a polyfill earlier than the code in the website itself. This may lead to problems, but when these polyfills are based on web standards, their behavior should be the same. What is the likelihood of there still being serious conflicts?
I found an interesting discussion about this on a github issue. This talks mostly about modules in the NPM ecosystem though, whereas I'm mostly interested in external scripts that facilitate things like widgets or embeds.
Any personal experience or links to discussions and articles on the subject is appreciated!
UPDATE: One of the main reasons for this question is that there were some issues with transform-runtime. With the new release of core-js and babel these issues seem to have been addressed. Regardless I am still interested in answers to the original question above.