An old version of jquery is being loaded into my masterpage and I can't figure out where it's coming from.

Looking at the masterpage, I see

SharePoint:ScriptLink ID="ScriptLink1" language="javascript" Defer="true" runat="server"

When the page is loaded it has a series of other scripts and one points to an invalid location, the one being in question is..........

document.write('<script type="text/javascript" src="/siteassets/jquery-1.7.min.js"></' + 'script>');

I've checked every solution and custom solution I've written and all are good. Obviously it was added at some point.... now how to find out where and get it out?

  • Are you able to reproduce it in a test/dev environment? – Per Jakobsen May 31 '12 at 17:15
  • It's singular to this environment unfortunately. – CeeMoney May 31 '12 at 17:26

If it gets loaded, it means it's there. So if you can't find it on the site itself, start looking through the layouts folder.

As you can see on the picture below within the markings, this shows you where the file is loaded from.

All javascript files located in the _layouts folder will be loaded on the page.

As you can see in the red marking, there are 2 js files located in the 1030 language folder being loaded, and in the orange you can see all the js files located in the _layouts directly being loaded.

If there were other js files being loaded onto the page, their paths would be displayed in this box. Open your site in IE > press F12 > Go to "Script" tab > Click on dropdown to the left of the "Start debugging" button. It should display all javascript files being loaded and where they are located.

Javascript load location

I hope this helps :)

|improve this answer|||||
  • I'm trying to find out how that reference is getting added to the masterpage. It's not in a page layout or on the masterpage directly, so it must be a CustomAction that's adding a scriptlink. Where are scriptlinks loaded from? I'm sure it's from an old sandbox solution that's been removed, but I can't find it. – CeeMoney Jun 1 '12 at 18:52
  • They are usually loaded from layouts folder (1033 subfolder, if it's a site using the english language package). e.g. /_layouts/1033/<js file> – user2536 Jun 1 '12 at 19:04
  • @CeeMoney Review my updated answer. – user2536 Nov 13 '12 at 13:12

This looks like one of your web parts has registered a script dependecy. One way to test this is to create a new page based on the Blank Web Part Page layout and then check to see if the script is being loaded. If not, then it is a webpart. If it is still being loaded, then check your page layouts, master page and any feature that makes use of delegate controls.

|improve this answer|||||
  • It's not the master page or any page layouts, and I've checked every custom feature that I've built or have source for. I'm scratching my head. – CeeMoney May 31 '12 at 17:11
  • Does the script get included when you create a new blank web part page and load that? – Dave Wise May 31 '12 at 17:17
  • Just checked... yes it's included. – CeeMoney May 31 '12 at 17:25
  • You also might want to look for the include in any custom .ASCX files that are in your CONTROLTEMPLATES folder below your 14 hive. If one is there, it might point you to the feature where it is being included – Dave Wise May 31 '12 at 17:34

Try running this in PowerShell:

dir 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14' -Recurse |  
Select-String -Pattern "jquery-1.7.min.js" -SimpleMatch -List |  
Select Filename

It should return the name of any file containing that string in SharePointRoot

|improve this answer|||||
  • Only reference was logs. – CeeMoney May 31 '12 at 17:55
  • I'd try looking at the entries in one of the log files to see if it gives a hint. Otherwise try running against c:\windows\assembly – Per Jakobsen May 31 '12 at 18:00
  • Logs just say that the file can't be found. No hits on the C:\windows\assembly search – CeeMoney May 31 '12 at 19:06

If this is a publishing site, you might also consider checking your Page Layouts, and not just your Master Pages.

|improve this answer|||||
  • I have double-checked those as well. – CeeMoney May 31 '12 at 20:18

Are there any custom actions being used to load some ScriptLink?

You can also check if there is any delegate control (along with their Sequence nos) loading the Javascript

|improve this answer|||||
  • How can I find that out? – CeeMoney May 31 '12 at 20:35
  • Check if there exists any custom Feature which is creating a custom action to load ScriptLink? Check Cisual Studio solutions. – Falak Mahmood May 31 '12 at 22:09
  • Also, use IE Developer tools to delete the browser cache, or try using IE private browsing. – Falak Mahmood May 31 '12 at 22:11
  • I've checked all of the custom features/solutions that are loaded and can't find anything, that's what's baffling. – CeeMoney May 31 '12 at 22:22
  • Is there a specific page layout that is loading it or a master page? – Falak Mahmood May 31 '12 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.