Anticipating a future, I am experimenting with User Custom Actions in the new Document Library View Microsoft has so kindly provided to the First Release Office365 tenants.
Since there is almost nothing SharePoint left (no JSOM, no SOD) I am trying new technologies to get JS library dependencies working.
Note that Microsoft does load RequireJS, but if they can get rid of the SP Object, JSOM etc.
I am not going to rely on anything but a modern Browser
fetch
is Chrome and Firefox only for now (april 2016) http://caniuse.com/#feat=fetch
fetch('https://.../file.js')
.then(function (q) {
return q.text();
})
.then(eval) //for those who think evil! It does the same as the (old) DOM abusing below
.then(function(){
//do stuff
});
Since this is all Promises, this would make loading multiple libraries a breeze
Any cons in using this over:
(good old abusing the DOM for no reason other then get a file loaded/executed):
var element = document.createElement("script");
element.src = "https://.../file.js";
element.load = function(){
//do stuff
}
document.head.appendChild(element);
fetch
be restricted by Same Origin Policy? And thinking about future, isn't eval (by default) disallowed in Content Security Policy?eval
is used in the new Library View CoreMinShellG2BundleA library; Microsoft has no intention yet to go CSP