Scripts Not Loading from Master Page after a 2013 to 2016 Migration

It Started as a Normal Migration

A while back we successfully upgraded a client’s on-premises SharePoint from 2013 to 2016.  This client has several sites that are highly customized, with complex master pages and lots of supporting JavaScript and CSS.  The migration went smoothly and all has been running without incident ever since. But eventually, the problem of scripts not loading from the master page would eventually cause a problem.

The Problem – Not Displaying “Apps you can add” Section

Now here we are over a year later and we had a need to make an update to the master page on one of the sites for the first time since the migration.  The fix we needed to apply had to do with the ‘Add an App’ page and its ability to show the ‘Apps you can add’ section correctly.

This site is outward-facing and highly customized, so we had hidden many of the OOTB SharePoint navigation and other links from the users when first implementing it.  In doing this though, the ‘Apps you can add’ section also ended up hidden.  In order to correct this problem, we needed to insert a single line of HTML into the master page to make it visible again.  I found this article by Elio Struyf to be extremely helpful in resolving this issue, with its clear explanation and solution.  Thanks, Elio!

For the curious, here is the line we needed to add and it did indeed solve our problem.

<span id="ms-pageTitleCurrentNode" style="display:none;"></span>

The ‘Apps you can add’ zone requires this for some reason and it doesn’t really matter where on the page it is, as long as it’s there.  You can read Elio’s post about it for more details.

Ripple Effect – Custom Script Files Were no Longer Loading

Which leads me to the real problem I decided needed a call out.  After applying this update to the master page, we suddenly started seeing jQuery errors on certain pages and some of our custom code was no longer running.  Huh?  It was working just fine before this other change.  How would inserting a cause a jQuery error?

The only other change that had been made was the installation of some third-party software for a project we were working on.  So, of course, our first thought was that there might be a jQuery conflict somewhere.  This took us down many rabbit holes in the pursuit of a solution but was ultimately not the problem.

As I continued to pursue, I finally figured out that our jQuery file along with one of our custom JavaScript files were not being loaded anymore from the master page.  Weird.  Remember nothing had changed in our site.  The files were still in the same library and were being loaded the same way as before.  The only change was the insertion of one line into the master page.

After much angst, I finally tracked down a solution to the problem.  In the body of our master page, we were loading our scripts using regular script tags, like so:


<script type="text/javascript" src="/_catalogs/masterpage/test/scripts/jquery.min.js"></script>

<script type="text/javascript" src="/_catalogs/masterpage/test/scripts/ test.js"></script>

The Solution to Scripts Not Loading From Master Page

These script tags were being completely ignored.  It wasn’t until I changed them to be SharePoint:ScriptLink calls, that they finally started loading correctly.


<!--MS:<SharePoint:ScriptLink language="javascript" name="~sitecollection/_catalogs/masterpage/test/scripts/jquery.min.js" OnDemand="false" runat="server" Localizable="false">-->


<!--MS:<SharePoint:ScriptLink language="javascript" name="~sitecollection/_catalogs/masterpage/test/scripts/test.js" OnDemand="false" runat="server" Localizable="false">-->



Ok, yes this is a best practice for loading scripts from a master page and it’s good to have these now loading the ‘correct’ way.  But why did they work with script tags before and not after a simple change to something unrelated?  I certainly do not know myself.  I read a lot of articles while trying to resolve this but never found a clear explanation. The closest I got was one article that said <script> tags are not supported by MDS (Minimal Download Strategy).  But we have MDS turned off for this site, so that’s not it.

Here I slide into mere speculation as I’m truly clueless.  My best guess is that something in SharePoint 2016 (and on up) is now requiring ScriptLink tags instead of plain <script> tags.  Once we touched the page for the first time since migration, this check was triggered.  Which of course makes zero sense but is the only thing I can come up with.  It had been working fine for a year with the <script> tags, until the day we touched the page.

Does anyone out there have a true explanation?  Feel free to share it in the comments!  I would love to know.

Caroline SosebeeScripts Not Loading from Master Page after a 2013 to 2016 Migration

Join the conversation

This site uses Akismet to reduce spam. Learn how your comment data is processed.