使用HMTL5 API监控前端性能

    <body>
        <img src="https://upload-images.jianshu.io/upload_images/3132443-74e353e9c1c0402b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700" alt="image">
        <script type="text/javascript">
            var measure_start = performance.now();
            document.getElementsByTagName("img")[0].addEventListener("load", function() {
                var measure_end = performance.now();
                console.log("加载时间: " + (measure_end - measure_start) + "ms");
            }, false);
        </script>
    </body>

公众号:瓶庵公园

    原文作者:歪歪1993
    原文地址: https://www.jianshu.com/p/f2fd37bd2b0d
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞