Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Measuring performance

From: Mobile Web Design & Development Fundamentals

Video: Measuring performance

In this chapter, we are going to take a look at some of the various capabilities and vendor-specific extensions that certain mobile web browsers have. That's because several mobile browsers provide vendor-specific extensions and capabilities to customize the way that users experience the web on that particular platform. These capabilities take some different forms. They come in the form of CSS extensions, meta tags, JavaScript functions, special objects, et cetera. Now using these features your pages can provide an experience that feels more native and takes advantage of specific platform abilities.

Measuring performance

In this chapter, we are going to take a look at some of the various capabilities and vendor-specific extensions that certain mobile web browsers have. That's because several mobile browsers provide vendor-specific extensions and capabilities to customize the way that users experience the web on that particular platform. These capabilities take some different forms. They come in the form of CSS extensions, meta tags, JavaScript functions, special objects, et cetera. Now using these features your pages can provide an experience that feels more native and takes advantage of specific platform abilities.

And the nice thing about this is that as long as your code it right and do client-side feature detection like we talked about earlier, the unsupported features simply don't show up on platforms that don't support them. So, the first one we are going to look at is how to measure performance of your mobile web site. Now measuring performance is an important subject just in and of itself, but up until recently, there was no real good integrated way to do this in the browser. That's changed because there is now a built-in interface for measuring performance, but it's currently only implemented by Internet Explorer 9 on both desktop and mobile.

The way that you use this is on the window.performance object, and the window. performance object stores performance information that is automatically recorded by the browser in the background and then made available to scripts that want to examine the information and then make use of it, either display it, or report it back to the server, or whatever. When the page finishes loading you can write script that looks at the data in the performance object to see how long each stage of the process of requesting the page from the server and loading it into the browser so the user can see it took, and we are going to look at code that does that.

There are two properties on the window performance object that help you to do this. The first one is navigation, and the navigation object describes the type of navigation, whether it was navigation or reload or such, and the number of redirect accounts that it took to get the page from the server to the browser. The timing object contains a lot of fields that measure various navigation time points. So let's take a look at some of those. This is a partial table of some of the time points that IE measures when the page-loading process is going on.

So right at the top there, navigationStart, that's the first time point that will get measure. That's the time at which the page-navigation process begins. By measuring that time point, you can then look at other time points to see how much time elapsed between when the navigation first started and something that you're interested in happened. So for example, by subtracting off the requestStart time, which is down here and that's what measures the time when the document was first requested, actually requested from the host server.

By measuring that time point and subtracting it off from the navigationStart, you can see how much time elapsed between when the navigation began and when the document was actually requested from the server. If we take a look at some more of the properties, you can see that there's more property that have to do with the page itself and the DOM. So for example, you can see that there is a property for domLoading. There is a property for domInteractive. So domLoading measures the time point at which the DOM of the page began to actually load in the window, and domInteractive indicated the time points at which the document was able to process user events-- in other words, the time point at which the user was able to start interacting with the document.

You can also see the domComplete time point, which is when the DOM was completely initialized for the loaded document. Then finally, there is event such as loadEventStart and loadEventEnd, which indicate the time points for when the onload event for the document was started and completed. So for example, by subtracting loadEventEnd off of navigationStart, you can see how long the entire page-loading process took. So let's take a look at how to use some code to see various performance data about our web page. So here I am in the code.

This is my performance_start.html file, which is in the example folder. And I've got my snippet file as well. And let's scroll down to the Mobile Performance Measuring section. So what I am going to do is copy this function here, calcPerfNumbers, and I will copy that and put it in here. We'll get back to that in a second. I am also going to copy the init function and the window.onload statement, and we'll paste those in.

So when the window loads, it's going to call the init function, and all init is going to do is call setTimeout on calcPerfNumbers, with a delay of about half a second. So after about a half a second within the time completing of the window.onload event handler, this function here will get called. And you can see that I am using feature detection to see if the window.performance object exists. And if it exists, I'll be able to go and calculate various time points. And if it doesn't exist, I am just going to show an error messages here that says, "Hey, you know this does not support the performance object." But if it does, then I am going to measure some various time points.

And then down here in the document you can see that I've got various spans where I am going to substitute in the time points that I am measuring. So here's one for requeststart, this is the onLoad time, this is when DOM Complete was, and this entire page load time right here. So let's go back up to our code. So the way that I calculate various time points is, for example, by taking the time point that I am interested in and subtracting off the navigationStart event.

So by taking requestStart and subtracting navigationStart, I can see how many milliseconds it took from the time that navigation started until the time that the page actually got requests from the browser and so on so forth. Here I am subtracting loadEventStart from loadEventEnd, which will tell me how long the Windows onLoad event handler took to execute. Then I am going to measure the entire page loading time by subtracting navigationStart from the loadEventEnd, and that will give me the entire time of the page-loading process.

So let's go ahead and save this. And now I am going to go copy this to my server. So I'll copy this over here, and we'll put it in. So here in the Windows Phone emulator you can see I have already got it running, but because it didn't have any code in there, there are no values. So now that I've copied the file in, I am just going to refresh it. And you can see that after about half a second of the page loading, we're getting various pieces of performance data.

So it took about 448 milliseconds, or about a half a second, from the time that the emulator issued a request to the local host server until the page began to load. You can see that the whole onLoad event handler took 1 millisecond to execute. It was about 700 milliseconds from the time that the navigation started until the DOM was complete, and the entire page loading time from start to finish took 760 milliseconds, So less than 1 second. so that should give you some idea of how you can use the new performance timing event object inside Internet Explorer to measure how well your web site applications perform, at least for now in IE, until other web browsers begin to implement the same interface.

Show transcript

This video is part of

Image for Mobile Web Design & Development Fundamentals
Mobile Web Design & Development Fundamentals

46 video lessons · 24271 viewers

Joe Marini
Author

 
Expand all | Collapse all
  1. 2m 48s
    1. Welcome
      1m 2s
    2. Using the exercise files
      1m 46s
  2. 29m 25s
    1. Understanding the mobile context
      8m 5s
    2. A survey of mobile sites
      11m 44s
    3. Targeting mobile browsers
      4m 31s
    4. Previewing a complete mobile site
      5m 5s
  3. 27m 20s
    1. Designing for one web
      3m 43s
    2. Using well-defined web standards
      3m 45s
    3. Designing mobile-friendly pages
      3m 40s
    4. Being crisp, clean, and succinct
      5m 45s
    5. Minimizing input where possible
      6m 47s
    6. Focusing on the core scenarios
      3m 40s
  4. 1h 13m
    1. Installing the tools
      3m 52s
    2. Setting up a local web server
      9m 13s
    3. Installing device emulators
      17m 5s
    4. Using device emulators
      13m 9s
    5. Downloading Modernizr and Mobile Boilerplate
      6m 22s
    6. Building a first mobile web page
      5m 43s
    7. Developing mobile pages with desktop browsers
      8m 6s
    8. Exploring useful mobile web development resources
      10m 23s
  5. 53m 26s
    1. Reviewing mobile markup languages
      5m 10s
    2. Understanding content adaptation approaches
      10m 32s
    3. Controlling the viewport layout
      12m 50s
    4. Designing forms
      13m 30s
    5. Using CSS media queries
      11m 24s
  6. 1h 11m
    1. Detecting client capabilities with script
      10m 8s
    2. Caching information with local storage
      9m 16s
    3. Determining position with geolocation
      12m 52s
    4. Minimizing HTTP requests with data URLs
      7m 39s
    5. Understanding user agent detection
      9m 8s
    6. Using server-side detection with PHP
      6m 52s
    7. Using server-side detection with ASP.NET
      4m 54s
    8. Using HTML5 Boilerplate for mobile
      11m 6s
  7. 39m 22s
    1. Measuring performance
      7m 41s
    2. Creating full-screen web apps
      6m 30s
    3. Customizing the user interface
      5m 14s
    4. Detecting orientation changes
      3m 58s
    5. Detecting device movement
      5m 21s
    6. Using touch events
      10m 38s
  8. 47m 14s
    1. Taking a look at the finished site
      7m 40s
    2. Examining the header and background image style on the Home page
      10m 10s
    3. Examining the hover effect and layout styles on the Tours page
      6m 42s
    4. Examining mobile forms on the Contact page
      9m 45s
    5. Viewing and testing the mobile site on emulators
      8m 11s
    6. Viewing the site on devices
      4m 46s
  9. 2m 34s
    1. Goodbye
      2m 34s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Mobile Web Design & Development Fundamentals.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.