简体   繁体   中英

How can we store time of js load with page load time?

Exaple:-

From this side you can see all information about over page. http://tools.pingdom.com/fpt/#!/b9eJAg/www.google.com

How can we store for our all page.

Try this:

<doctype html>
<html>
<head>
    <script type="text/javascript">
       var timerStart = Date.now();
    </script>
    <!-- do all the stuff you need to do -->
</head>
<body>
    <!-- put everything you need in here -->

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

    <script type="text/javascript">
         $(document).ready(function() {
             console.log("Time until DOMready: ", Date.now()-timerStart);
         });
         $(window).load(function() {
             console.log("Time until everything loaded: ", Date.now()-timerStart);
         });
    </script>
</body>
</html>

Source: https://stackoverflow.com/a/14343144/3185456

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM