2 * jQuery Mobile v@VERSION
3 * http://jquerymobile.com/
5 * Copyright 2011, jQuery Project
6 * Dual licensed under the MIT or GPL Version 2 licenses.
7 * http://jquery.org/license
10 // This is code that can be used as a simple bookmarklet for timing
11 // the load, enhancment, and transition of a changePage() request.
13 (function( $, window, undefined ) {
17 return ( new Date() ).getTime();
20 var startChange, stopChange, startLoad, stopLoad, startEnhance, stopEnhance, startTransition, stopTransition, lock = 0;
23 .bind( "pagebeforechange", function( e, data) {
24 if ( typeof data.toPage === "string" ) {
25 startChange = stopChange = startLoad = stopLoad = startEnhance = stopEnhance = startTransition = stopTransition = getTime();
28 .bind( "pagebeforeload", function() {
29 startLoad = stopLoad = getTime();
31 .bind( "pagebeforecreate", function() {
33 stopLoad = startEnhance = stopEnhance = getTime();
36 .bind( "pageinit", function() {
38 stopEnhance = getTime();
41 .bind( "pagebeforeshow", function() {
42 startTransition = stopTransition = getTime();
44 .bind( "pageshow", function() {
45 stopTransition = getTime();
47 .bind( "pagechange", function( e, data ) {
48 if ( typeof data.toPage === "object" ) {
49 stopChange = getTime();
51 alert("load + processing: " + ( stopLoad - startLoad )
52 + "\nenhance: " + ( stopEnhance - startEnhance )
53 + "\ntransition: " + ( stopTransition - startTransition )
54 + "\ntotalTime: " + ( stopChange - startChange ) );
56 startChange = stopChange = startLoad = stopLoad = startEnhance = stopEnhance = startTransition = stopTransition = 0;