SharePoint Waiting for SP.js to Load

We spent our day here at my FT job trying to figure this our out … me a senior level .NET developer and two senior level SharePoint masters.

First we had nice newly created web part, running a jQuery based carousel of pictures.  Everything was working fine, until we launched it to our SharePoint 2013 publishing page.  SP 2013 Team Pages worked just fine, SP 2010 worked just fine, and edit mode of the SP2013 publishing page worked just fine … but when we moved it to Checked In and Published, literally the web part just stopped.

Also 3 hours later we found what was happening:

We were running the command:

ExecuteOrDelayUntilScriptLoaded(function () { myFunc(); }, "sp.js");

We wanted to make sure that “sp.js” was loaded BEFORE calling our “myFunc” call … well on publishing pages in SP 2013 … they have changed the function for this to

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', myFunc);

Gosh … there is 3 hours lost on my day … jeepers; we made the switch and everything worked immediately

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: