Customizing the SharePoint 2013 Developer Dashboard using custom scripts

In SharePoint 2013 Dev dash has helped the admins to help troubleshoot a lot of performance issues .
The Developer Dashboard can now be extended by injecting custom JavaScript code into the developer dashboard window.

Two steps are necessary to achieve this:

1.Custom JavaScript code, which interacts with the developer dashboard DOM, has to be added to a script file that can be accessed from the Developer Dashboard page. E.g. by placing the script file into the _layouts/15 directory.

2.The custom script file(s) have to be registered to be loaded into the Developer Dashboard page.
Below is a short example, which hides the ULS tab in the Developer Dashboard. This example also shows how to use jquery within the Developer Dashboard.

Create the custom logic in a script file
Create a “hideULSTab.js” inside the layouts/15 directory (program files\common files\microsoft shared\web server extensions\15\template\layouts) and add the following script code to it:
// register a code block that runs after the page is loaded
$(document).ready(function()
{
   // iterate over all tabs (identified by CSS class “ms-dd-Tab”)
   $(‘.ms-dd-Tab’).each(function(index, para)
   {
      // look for the tab which has “ULS” title
      if ($(para).text().indexOf(“ULS”) !== -1)
      {
         // hide the title
         $(para).hide();
      }
   });
});

Register the script files with the Developer Dashboard

Our custom script code requires the jquery library – so we have to register two script files with the developer dashboard. That can be done using the following powershell commands:

$contentSvc = ([Microsoft.SharePoint.Administration.SPWebService]::ContentService)
$DevDashboardSettings = $contentSvc.DeveloperDashboardSettings
$DevDashboardSettings.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On

$DevDashboardSettings.userscripts.Add(“http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.0.min.js”)
$DevDashboardSettings.userscripts.Add(“/_layouts/15/hideULSTab.js”)

$DevDashboardSettings.Update()

As you can see we are registering two different script files: first the jquery library from an external site and second the script file we created earlier.

The powershell script will also enable the Developer Dashboard by setting the DisplayLevel to on.

http://blogs.technet.com/b/stefan_gossner/archive/2013/01/23/customizing-the-sharepoint-2013-developer-dashboard-using-custom-scripts.aspx

Advertisements

About Pratik Vyas

Hi Readers, Welcome to Pratik’s SharePoint Blog. First of all Thank you very much for taking interest and spending time to tour my Blog I am in the ocean of SharePoint since January 2008 (almost 4 years), and still I feel I have to go more deep. I am working with a well known MNC as a SharePoint Consultant. Here I used consultant because I do a little development and customization with administration. I am very much interested in Microsoft products. I have started blogging since 2008 but I can say in real manner I have started it in 2011 (as I have posted only 4-5 blogs from 2008 to 2011 J) I believe there isn’t anything impossible in SharePoint, the only thing is sometimes we have to think something off track. I have posted couple of blogs which was discovered by going some off track, we can simply say it TRICKS. Feel free to reach me in case of any issues or queries I will be more than happy to help you. Good bye and Happy Reading, Cheers !!
This entry was posted in Developer Dashboard, Developer Dashboard using custom scripts, SharePoint 2013, SP2013. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s