Answered Cannot use CDN /w SP.SOD

  • Friday, May 27, 2011 8:57 PM
     
     

    Unable to use jQuery from CDN for web part using Script-on-Demend (SOD), since all scripts require the last line to be:  SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs(...) which is not in the CDN versions.

    The result of omitting line results in the jQuery to be loaded multiple times, and any dependent javaScript file will never load.

    Anyone able to use SP.SOD with a CDN?

Answers

  • Monday, May 30, 2011 12:58 PM
     
     Answered

    To be more correct, SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs is required by SharePoint to load dependent javascript files and not reload javascript.

    So, since it is required for all javascript loaded On-Demend, a CDN cannot be used, this is at least how the SP.SOD is working.

    I agree SharePoint should already know when a javascript has loaded without SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs as their last line in the file, but SOD will not work correctly without them.  The example you have linked includes the last line so it is required by design; and would be required as last line in the jQuery script file which is not included from any CDN.

    • Edited by MULTISY Monday, May 30, 2011 1:03 PM By Design
    • Marked As Answer by MULTISY Monday, May 30, 2011 1:03 PM
    •  

All Replies

  • Monday, May 30, 2011 7:36 AM
    Moderator
     
     

    Hi,

    The SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs method comes from SharePoint instead of Jquery.

    http://msdn.microsoft.com/en-us/library/ff410742.aspx

    If you want to know which js file contain the method definiton above you can see the folowing document.

    http://msdn.microsoft.com/en-us/library/ee538253.aspx


    Microsoft Online Community Support
  • Monday, May 30, 2011 12:58 PM
     
     Answered

    To be more correct, SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs is required by SharePoint to load dependent javascript files and not reload javascript.

    So, since it is required for all javascript loaded On-Demend, a CDN cannot be used, this is at least how the SP.SOD is working.

    I agree SharePoint should already know when a javascript has loaded without SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs as their last line in the file, but SOD will not work correctly without them.  The example you have linked includes the last line so it is required by design; and would be required as last line in the jQuery script file which is not included from any CDN.

    • Edited by MULTISY Monday, May 30, 2011 1:03 PM By Design
    • Marked As Answer by MULTISY Monday, May 30, 2011 1:03 PM
    •