11 February, 2013

Customizing the SharePoint 2013 Developer Dashboard using custom scripts

Wow Stefan Gobner has shared a wonderful article on Customising Dev Dash in 2013.

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
   // 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

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



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.



Your feedback is always appreciated. I will try to reply to your queries as soon as possible- Amol Ghuge

Note: Only a member of this blog may post a comment.