title: SharePoint Foundation 2013 - Order of loading sp.js and sp.runtime.js
body: <p>I have problem with an order in which I am loading </p>
  
  <pre><code>&lt;script type="text/javascript" src="/_layouts/15/sp.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/_layouts/15/sp.runtime.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>on my page</p>
  
  <p>This is the whole head section on my master page.</p>
  
  <pre><code>&lt;head runat="server"&gt;
      &lt;meta name="GENERATOR" content="Microsoft SharePoint" /&gt;
      &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=10"/&gt;
      &lt;meta http-equiv="Expires" content="0" /&gt;
      &lt;SharePoint:SPPinnedSiteTile runat="server" TileUrl="/_layouts/15/images/SharePointMetroAppTile.png" TileColor="#0072C6" /&gt;
      &lt;SharePoint:RobotsMetaTag runat="server"/&gt;
      &lt;SharePoint:PageTitle runat="server"&gt;
          &lt;asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server"&gt;
              &lt;SharePoint:ProjectProperty Property="Title" runat="server" /&gt;
          &lt;/asp:ContentPlaceHolder&gt;
      &lt;/SharePoint:PageTitle&gt;
      &lt;SharePoint:SPShortcutIcon runat="server" IconUrl="/_layouts/15/images/favicon.ico?rev=23" /&gt;
      &lt;SharePoint:StartScript runat="server" /&gt;
      &lt;SharePoint:CssLink runat="server" Version="15"/&gt;
      &lt;SharePoint:CacheManifestLink runat="server"/&gt;
      &lt;SharePoint:ScriptLink language="javascript" name="core.js" OnDemand="true" runat="server" Localizable="false" /&gt;
      &lt;SharePoint:ScriptLink language="javascript" name="menu.js" OnDemand="true" runat="server" Localizable="false" /&gt;
      &lt;SharePoint:ScriptLink language="javascript" name="callout.js" OnDemand="true" runat="server" Localizable="false" /&gt;
      &lt;SharePoint:ScriptLink language="javascript" name="sharing.js" OnDemand="true" runat="server" Localizable="false" /&gt;
      &lt;SharePoint:ScriptLink language="javascript" name="suitelinks.js" OnDemand="true" runat="server" Localizable="false" /&gt;
      &lt;SharePoint:CustomJSUrl runat="server" /&gt;
      &lt;SharePoint:SoapDiscoveryLink runat="server" /&gt;
      &lt;SharePoint:AjaxDelta id="DeltaPlaceHolderAdditionalPageHead" Container="false" runat="server"&gt;
          &lt;asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" /&gt;
          &lt;SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true" /&gt;
          &lt;asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat="server" /&gt;
      &lt;/SharePoint:AjaxDelta&gt;
      &lt;SharePoint:CssRegistration Name="Themable/corev15.css" runat="server" /&gt;
      &lt;script type="text/javascript" src="/_layouts/15/sp.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="/_layouts/15/sp.runtime.js"&gt;&lt;/script&gt;
  
  
      &lt;SharePoint:ScriptLink ID="ScriptLink1" runat="server" Name="~sitecollection/_catalogs/masterpage/Resources/js/jquery-1.11.0.min.js" Language="javascript" /&gt;
      &lt;SharePoint:ScriptLink ID="ScriptLink3" runat="server" Name="~sitecollection/_catalogs/masterpage/Resources/js/global.js" Language="javascript" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="Resources/css/quack_1200.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="Resources/css/main.css" /&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>Following order breaks my code like this (when I am trying to work with sp context):</p>
  
  <pre><code>&lt;script type="text/javascript" src="/_layouts/15/sp.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="/_layouts/15/sp.runtime.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/bJr9B.png" alt="enter image description here"></p>
  
  <p>However if I switch the order of the scripts like this I don't get the previous error but I get following error if I try to go to a list and click on an "Edit" button.</p>
  
  <pre><code>&lt;script type="text/javascript" src="/_layouts/15/sp.runtime.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="/_layouts/15/sp.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/pEzqN.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/4OGJz.png" alt="enter image description here"></p>
  
  <p>Any help on this confusing issue would be very much appreciated.</p>