title: Shopify site loading JS files immediately
body: <p>I am attempting to optimize the speed on my Shopify site and I am told that I need to load external CSS files before external JS files. In the theme.liquid file, I made sure to move all external CSS files before the external JS files. However, when I load the website, it is showing several JS files at the very top of the opening <code>&lt;head&gt;</code> tag. I am completely unsure of where these files are being loaded from. How can I force these files to load after the external files?</p>
  
  <p><a href="https://i.stack.imgur.com/FPWXE.png" rel="nofollow noreferrer">Inspector HTML</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;!--[if lt IE 7 ]&gt;&lt;html class="ie ie6" lang="en"&gt; &lt;![endif]--&gt;
  &lt;!--[if IE 7 ]&gt;&lt;html class="ie ie7" lang="en"&gt; &lt;![endif]--&gt;
  &lt;!--[if IE 8 ]&gt;&lt;html class="ie ie8" lang="en"&gt; &lt;![endif]--&gt;
  &lt;!--[if (gte IE 9)|!(IE)]&gt;&lt;!--&gt; &lt;html lang="en"&gt; &lt;!--&lt;![endif]--&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
  
    &lt;!-- Basic Page Needs
  ================================================== --&gt;
    
    &lt;title&gt;
      {{ page_title }}{% if current_tags %} &amp;ndash; tagged "{{ current_tags | join: ', ' }}"{% endif %}{% if current_page != 1 %} &amp;ndash; Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} &amp;ndash; {{ shop.name }}{% endunless %}
    &lt;/title&gt;
    {% if page_description %}
    &lt;meta name="description" content="{{ page_description | escape }}" /&gt;
    {% endif %}
    &lt;link rel="canonical" href="{{ canonical_url }}" /&gt;
  
    {% include 'social-media-meta-tags' %}
    
    &lt;!-- CSS
  ================================================== --&gt;
  
    {{ 'stylesheet.css' | asset_url | stylesheet_tag }}
    {{ 'font-awesome.css' | asset_url | stylesheet_tag }}
    {{ 'queries.css' | asset_url | stylesheet_tag }}
    {{ "fonts.css"  | asset_url | stylesheet_tag }}
    {{ 'bold.css' | asset_url | stylesheet_tag }}
    {{ 'custom.css' | asset_url | stylesheet_tag }}
    {{ 'rewards.css' | asset_url | stylesheet_tag }}
  {% include 'bold-product' with product, hide_action: 'header' %}
  
    {% include 'google-fonts' %}
    &lt;!--[if LTE IE 8]&gt;
    {{ 'gridlock.ie.css' | asset_url | stylesheet_tag }}  
    &lt;![endif]--&gt; 
      &lt;!--[if IE 7]&gt;
    {{ 'font-awesome-ie7.css' | asset_url | stylesheet_tag }}
    &lt;![endif]--&gt;
  
    {{ 'bold.css' | asset_url | stylesheet_tag }}
   
    
    &lt;!-- JS Script
  ================================================== --&gt;
    {% include 'limespot-global-head-includes' %}
    &lt;link rel="shortcut icon" href="{{ 'favicon.png' | asset_url }}"&gt;
    
  
    {% if template contains 'customers' %}
    {{ "shopify_common.js" | shopify_asset_url | script_tag }}
    {{ "customer_area.js"  | shopify_asset_url | script_tag }}
    {% endif %}
  
    {{ content_for_header }}
  
  
  
    
    &lt;script type="text/javascript"&gt;
  
      $(window).load(function() {  
        $('.prod-container').matchHeight();
  
      });
    &lt;/script&gt;   
    
  &lt;!-- Bold D&amp;H //theme --&gt;
  {% if product.metafields.inventory.ShappifyHidden == "true" %} &lt;meta name="robots" content="noindex"&gt; {% endif %}
  &lt;!-- // end theme D&amp;H --&gt;
    
  &lt;!-- Start of thegldshop Zendesk Widget script --&gt;
  &lt;script&gt;/*&lt;![CDATA[*/window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(c){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&amp;&amp;(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('&lt;body onload="document._l();"&gt;'),o.close()}("https://assets.zendesk.com/embeddable_framework/main.js","thegldshop.zendesk.com");
  /*]]&gt;*/&lt;/script&gt;
  &lt;!-- End of thegldshop Zendesk Widget script --&gt;
  
  
      {{ 'bold-helper-functions.js' | asset_url | script_tag }}
   
    
  &lt;!-- Facebook Pixel Code --&gt;
  &lt;script&gt;
  !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
  n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
  document,'script','https://connect.facebook.net/en_US/fbevents.js');
  
  fbq('init', '903638969718533');
  fbq('track', "PageView");&lt;/script&gt;
  &lt;noscript&gt;&lt;img height="1" width="1" style="display:none"
  src="https://www.facebook.com/tr?id=903638969718533&amp;ev=PageView&amp;noscript=1"
  /&gt;&lt;/noscript&gt;
  &lt;!-- End Facebook Pixel Code --&gt;
    
    &lt;meta name="google-site-verification" content="HBLWBeNWSyVpfKi1kphn9N-pawBjK09WMSV2F7MmVKU" /&gt;
    
  &lt;!-- Start Alexa Certify Javascript --&gt;
  &lt;script type="text/javascript"&gt;
  _atrk_opts = { atrk_acct:"V9iOn1QolK10cv", domain:"thegldshop.com",dynamic: true};
  (function() { var as = document.createElement('script'); as.type = 'text/javascript'; as.async = true; as.src = "https://d31qbv1cthcecs.cloudfront.net/atrk.js"; var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(as, s); })();
  &lt;/script&gt;
  &lt;noscript&gt;&lt;img src="https://d5nxst8fruw4z.cloudfront.net/atrk.gif?account=V9iOn1QolK10cv" style="display:none" height="1" width="1" alt="" /&gt;&lt;/noscript&gt;
  &lt;!-- End Alexa Certify Javascript --&gt;  
   
  &lt;!-- Start Crazy Egg Script --&gt;  
  &lt;script type="text/javascript"&gt;
  setTimeout(function(){var a=document.createElement("script");
  var b=document.getElementsByTagName("script")[0];
  a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/0055/5395.js?"+Math.floor(new Date().getTime()/3600000);
  a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
  &lt;/script&gt;  
  &lt;!-- End Crazy Egg Script --&gt;
    
    
  &lt;!-- Bing Tracking Code --&gt;
  &lt;script&gt;(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"5527824"};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&amp;&amp;s!=="loaded"&amp;&amp;s!=="complete"||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,"script","//bat.bing.com/bat.js","uetq");&lt;/script&gt;&lt;noscript&gt;&lt;img src="//bat.bing.com/action/0?ti=5527824&amp;Ver=2" height="0" width="0" style="display:none; visibility: hidden;" /&gt;&lt;/noscript&gt;
  &lt;!-- End Bing Tracking Code --&gt;  
    
    
    
    
    &lt;!-- JS External
  ================================================== --&gt;
  
  
    &lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
    
    {% assign custom = all_products.custom-set %}
    {% assign custom_handle = 'custom-set' %}
    &lt;script type="text/javascript"&gt;
      var customImage = "{{ custom | img_url: 'small' }}";
      var customHandle = "{{ custom_handle }}";
    &lt;/script&gt;
  
    {{ 'theme.js' | asset_url | script_tag }} 
    {{ 'option_selection.js' | shopify_asset_url | script_tag }}  
    {{ 'handlebars.js' | asset_url | script_tag }}
    {{ 'api.js' | asset_url | script_tag }}  
    {{ 'jquery.fs.shifter.js' | asset_url | script_tag }}
  
    {% if template == 'index' %}
    {{ 'instafeed.js' | asset_url | script_tag }}
    {% endif %}
    
    &lt;!--[if lt IE 9]&gt;
  &lt;script src="//html5shim.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
  &lt;![endif]--&gt;
  
    &lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"&gt;
    
  &lt;/head&gt;</code></pre>
  </div>
  </div>
  </p>