16

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);
  • Wouldn't fetch be restricted by Same Origin Policy? And thinking about future, isn't eval (by default) disallowed in Content Security Policy? – eirikb May 1 '16 at 18:53
  • Thats up to Microsoft. I have no idea how difficult it would be for them to implement.. but SharePoint is a 15 year old beast, I can image it would take some serious regression testing. In that aspect getting rid of all the (old) SharePoint shit in the new Document Library makes sense to me now. html5rocks.com/en/tutorials/security/content-security-policy – Danny '365CSI' Engelman May 2 '16 at 9:04
  • Judging by the handfull of times eval is used in the new Library View CoreMinShellG2BundleA library; Microsoft has no intention yet to go CSP – Danny '365CSI' Engelman May 2 '16 at 15:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.