0

I have an existing JSOM web-part which reference the SPO runtime:

,
    "sp-runtime": {
      "path": "https://abc/_layouts/15/SP.Runtime.js",
      "globalName": "SP",
      "globalDependencies": [
        "microsoft-ajax"
      ]
    },
    "sharepoint": {
      "path": "https://abc/_layouts/15/SP.js",
      "globalName": "SP",
      "globalDependencies": [
        "sp-runtime"
      ]
    },
    "sharepoint-doc-mgmt": {
      "path": "https://abc/_layouts/15/SP.DocumentManagement.js",
      "globalName": "SP",
      "globalDependencies": [
        "sharepoint"
      ]
    }

I then reference it:

require("sp-init");
require("microsoft-ajax");
require("sp-runtime");
require("sharepoint");

The part works as desired but initial load takes over a minute. After generating a performance report, I see that SP.Runtime.js script evaluation takes over a minute:

enter image description here

I am not sure how to reference the runtime so as to avoid the delay. Thanks.

0

You could try to load the libraries directly.

SPComponentLoader.loadScript('/_layouts/15/init.js', {
      globalExportsName: '$_global_init'
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/MicrosoftAjax.js', {
        globalExportsName: 'Sys'
      });
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/ScriptResx.ashx?name=sp.res&culture=en-us', {
        globalExportsName: 'Sys'
      });
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/SP.Runtime.js', {
        globalExportsName: 'SP'
      });
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/SP.js', {
        globalExportsName: 'SP'
      });
    })            
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/sp.init.js', {
        globalExportsName: 'SP'
      });
    })  
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/1033/strings.js', {
        globalExportsName: 'Strings'
      });
    }) 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.