I am new with poly filling and I have been looking at some articles about it, such as this simple one here. But with sharepoint not being able to load 3rd party scripts, can someone walk me through what the best way is to do so?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
I assume by not able to load 3rd party scripts, you mean that you can't reference scripts outside of your site collection in user custom actions?
If so, the easiest solution would be to put a script in your site collection, load it as a custom action, and have that script add a script tag to load the external resource. Taking the example that article gives, you can add a script with:
Put this script in your Style Library, and load it via a custom action. Make sure any other scripts you have that want to use Promise are loaded after this script (i.e. higher sequence number, or JSLink). And that's it, you now have a working pollyfill.
Normally, browsers that support the async attribute (all modern browsers) for scripts will load and execute dynamically added scripts (i.e. added through DOM manipulation or document.write) as quickly as possible, which means the second script could be executed before the first has been loaded. Browsers that don't support the async attribute will always load and execute scripts synchronously, whether dynamically added or not.
But, with this flag set to false, the dynamic script will pause further rendering until it has executed completely, which means the second script can count on the first script being ready for use from the start. And since browsers that don't support async are synchronous by default, this should work for them too (with some caveats).
The caveats are that due to bugs or partial implementation of async, the order of execution of these scripts is not guaranteed in IE 4-9 or Safari 5.0 (see async attribute for external scripts), but it should work reliably in all reasonably modern browsers.