SharePoint 2013, Web Parts and JavaScript Includes

I have a SharePoint 2010 Solution which I need to port to SharePoint 2013.  It has a page with a list on it and a lot of related JavaScript which handle some rendering of the page as well as a jQuery Tree view for navigation.   The original solution used a customized master page which referenced jQuery.js,  SPServices.js, sp.js, sp.core.js. sp.runtime.debug.js and several helper modules specific to the solution.

My goal is to not use  a customized master page for the port and to put these "master page" includes into a script web part.  Additionally I have a scripting web part to load the jquery tree view html file, a filter web part which allows the main list view to get filtered and another scripting web part which has a set of JavaScript modules which drive the page.

Much of the port seems to be shaping up.  But there are some issues which I think are related to when the various modules load which having them housed in the master page handled.

In particular,  I thought that having these lines in my top most web part would ensure that they would be available for all subsequent web parts:
<SharePoint:ScriptLink ID="ScriptLink21" Name="sp.js" runat="server" OnDemand="false"  LoadAfterUI="true" Localizable="false" />

<SharePoint:ScriptLink ID="ScriptLink22" Name="sp.Core.js" runat="server" OnDemand="false"  LoadAfterUI="true" Localizable="false" />

<SharePoint:ScriptLink ID="ScriptLink23" Name="sp.RunTime.Debug.js" runat="server" OnDemand="false"  LoadAfterUI="true" Localizable="false" />  <--Does ScriptLink tag work in web part or only on master pages?

Apparently I am missing something here and I am not getting these modules loaded first.

Any wisdom in general and specifically to what I am trying to accomplish would be greatly appreciated.

Also,  to reference the above modules, do I need to prefix their names with "_layouts/" ,  "_layouts/15/" or not?
Howard BashSenior Software EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Without seeing any of your code, and guessing on what could be happening (as I just went through this last week), you may need to have at the start of your WebPart the following:


Open in new window

This will allow the function to run once sp.js is installed. See if that helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.