Hide SharePoint Ribbons Using jQuery

Using the jQuery library, this is a nice way to hide SharePoint ribbons from appearing at the top of a SharePoint page. In this example, I am using it to hide the ribbon associated with Quest web parts which are used for generating various charts and graphs. I was not able to find or did not have access to a configurable setting to hide the ribbon, so I had to resort to hiding it programmatically in order to reduce clutter on the screen.

Add a Content Editor Web Part to the page and include the following script in the source (or as a reference to a script file). The setTimeout timer should be modified to meet your individual needs. In this particular instance, there is a slight delay after the page is loaded before the ribbon appears so I set the delay to 100 milliseconds to ensure that hide() was called after the ribbon was displayed.

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

<script type="text/javascript">
  $(document).ready(function() {
    setTimeout(function() {
      $('#Ribbon\\.QuestContextualTabGroup').hide();
    }, 100);
  });
</script>

The hardest part is trying to identify the appropriate ID of the element that needs to be hidden especially if the ribbon is generated dynamically as part of a script. I was able to find the ID using Firebug, but you may also use the following script to cycle through each of the ribbon tabs to find the one you want to hide.

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

<script type="text/javascript">
  $(document).ready(function() {
    setTimeout(function() {
      $("a.ms-cui-tt-a").each(function() {
        var strTabID = $(this).parent().attr("id");
        alert(strTabID);
      });
    }, 5000);
  });
</script>

Load jQuery Once Per Page in SharePoint

If you have several scripts on a SharePoint page that all need to reference the jQuery library file, then you may end up in a situation where the library is loaded multiple times. This will cause a conflict and various execution errors. The following script will load jQuery once per page in SharePoint.

This can be avoided by adding a Content Editor Web Part to the page and including the following script in the source (or as a reference to a script file). Once the page is loaded, the jQuery library file will be available to other scripts loaded on the page and you avoid having conflicts. The other scripts will no longer need to load the jQuery library so remove external file references in those scripts.

In this example, my copy of jQuery is stored in a Document Library labeled “code” which would need to be changed to align with your particular folder structure. I am also loading both the standard jQuery library and the SPServices jQuery library.

<script type="text/javascript" src="./code/jquery.js"></script>
<script type="text/javascript" src="./code/jquery.SPServices.js"></script>