You are visiting the High Monkey blog archive. Posts prior to 2016 may not meet accessibility standards. Please visit our current blog area at to view accessibility compliant blog posts published since January 1, 2016.

Order of Operations

Written By: High Monkey
Posted: 4/29/2011

(From the mind of Peter Serzo, Previously VP of Consulting Services at High Monkey)

Spring has finally come (I think). This past week I was tasked with replacing the welcome control:

This control is not what it seems at first and after some careful investigation I found a lesson I had learned before that has to do with the order of operations when a web page is rendered. This is the lesson contained within. Let's get to our story…

The site is going to be utilized by users who do not need a few things having to do with the Welcome control:

  1. The dropdown – it just becomes a matter of confusion. What may seem benign to us who use SharePoint all the time is not always simple. The key here: Simplify and get rid of the dropdown.
  2. Welcome domain/loginname – My example does not show it this way. The customer wanted 'Welcome, FirstName LastName'

After doing some investigation, I decided to go the jQuery/javascript route and with some simple CSS to hide the original control and add a simple control. This is how I did this:

  1. I cracked open SharePoint Designer and found the source of the control:

As you can see this renders by the server at browser render time.

  1. Looking at IE, Tools, View Source, I found the control after the page renders. What a mess. Let's just say it starts with this '<menu type='ServerMenu' id="zz3_ID_PersonalActionMenu" ' and keeps going for a bit. All I wanted to do is use jQuery to find the word Welcome (by traversing the DOM).
  2. I created some simple jQuery to find the word Welcome. After doing this it was simple to get the loginname via some parsing. I had to do this because the global variable _spuserID is not available on a customized master page. Trust me, I banged my head against a wall on this one.
  3. I then called the User Info list via web services to pull the name, using an Ajax call.
  4. Then I created a function to parse out the name as I wanted it.
  5. Finally, I wrote this name back to the page.

HERE IS THE LESSON (and point of this blog)

  1. I included both scripts at the top of the customized master page as follows:

<script type="text/javascript" src="/Javascript/jquery.js"></script>
<script type="text/javascript" src="/Javascript/WSSUserName.js"></script>

When I ran the page it did not work. It became very frustrating because in debugging my function, I could find nothing wrong with the code. But for "some" reason I could not find the word 'Welcome'. Even though I know it is there. This it hit me!!!!!!

Order of operations – I put the <script type="text/javascript" src="/Javascript/WSSUserName.js"></script> at the bottom of the page just before the </BODY>. I ran it again and everything worked perfect. The moral of the story – sometimes – Let the page load and then use jQuery to traverse the DOM. It cannot find what has not rendered.

Working with different clients that do use javascript, it is often advantageous to put the script at the bottom of the page because the site has better performance. As Yahoo states in High Performance Web Sites: sometime scripts block parallel downloads. When a script is downloading, the browser won't start any other downloads.

Lesson learned again.

Chad's Bio Coming Soon!

More About Virgil

Virgil Carroll is the owner and president of High Monkey – based in Minneapolis Minnesota. Virgil also wears the multiple ‘hats’ of Principle Human Solutions Architect and SharePoint Architect.

Virgil is one of those rare individuals who can dive deep into technical topics while speaking clearly to the business owners of a project and never forgetting that the end user experience has the highest priority. He calls it using both sides of his brain. Virgil is passionate about leveraging technologies ‘out of the box’ as much as possible with a focus on the strategic use of content to create websites that deliver the right content to the right audience on the right device at the right time. Virgil brings high energy, an ironic wit, and a sense of grounded perspective whenever he speaks to an audience. Virgil regularly speaks at conferences and user groups throughout the United States and occasionally in Europe.

Posted: 4/29/2011 12:00:00 AM by | with 0 comments
Filed under: