[HTML5] Track First Contentful Paint with PerformanceObserver and Google Analytics
"If you can't measure it, you can't improve it." The first step when doing performance work is to measure meaningful metrics to establish a baseline for improvement. In this lesson, we'll measure Time to First Contentful Paint, a user-centric performance metric. We'll first create a PerformanceObserver object and explore the information it captures. Next, we'll send that information to Google Analytics to track FCP over time. Lastly, we'll discover why PerformanceObserver is one of the few bits of Javascript that rightly belong in the head of your document.
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
console.log(entry.name, entry.startTime);
// note: the ga call will only work on your actual domain, make
// sure the code is executed on your domain and not just in a test environment.
ga('send', 'timing', entry.name, 'userId', Math.round(entry.startTime));
}
});
observer.observe({entryTypes: ['paint']});
[HTML5] Track First Contentful Paint with PerformanceObserver and Google Analytics的更多相关文章
- WebVTT 及 HTML5 <track> 元素简介
https://dev.opera.com/articles/zh-cn/an-introduction-to-webvtt-and-track/ 简介 网络视频文本轨道,简称为 WebVTT, 是一 ...
- What is Dark Social & Dark Traffic?
What is Dark Social & Dark Traffic? By Iaroslav Kudritskiy Google Analytics is supposed to speak ...
- Top 22 Free Responsive HTML5 Admin & Dashboard Templates 2018
Top 22 Free Responsive HTML5 Admin & Dashboard Templates 2018 May 18, 2018 Alex Ivanovs Website ...
- HTML5 Boilerplate - 让页面有个好的开始
最近看到了HTML5 Boilerplate模版,系统的学习与了解了一下.在各种CSS库.JS框架层出不穷的今天,能看到这么好的HTML模版,感觉甚爽.写篇博客,推荐给大家使用. 一:HTML5 ...
- HTML5定稿
HTML5定稿了,终于有一种编程语言开发的程序可以在Android和IOS两种设备上运行了 本文转载自: http://www.cnblogs.com/tuyile006/p/4103634.html ...
- HTML5移动Web开发(一)——HTML5和移动网站基本概念以及一些模拟器
当前,手机设备发展迅猛.屏幕尺寸各不相同.存储和性能仍有局限性,如何结合HTML5的功能,在多平台上创建高性能.响应式的移动网站,是Web开发者所要面对的首要挑战.HTML5以及移动网站都是很有前景的 ...
- Web 开发精华文章集锦(jQuery、HTML5、CSS3)【系列二十七】
<Web 前端开发精华文章推荐>2014年第6期(总第27期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...
- html5的发展历程和由此引起的政治斗争
2007年,乔布斯断言拒绝Flash并预言HTML5时代来临,IT行业就对HTML5产生了一股宗教热情.HTML5有着许多出众的特性,可以直接在网页上绘图.嵌入音视频.实现信息互动,可以跨越iOS.A ...
- html5的发展历程
20年磨一剑,HTML5作为下一代Web标准,她的语义之美.人性之美.简单之美.实用之美……如同一场革命,将Web从内容平台推向标准化的应用平台,并一统各在平台阵营的标准.2008年,HTML5发布首 ...
随机推荐
- 云平台学习--GitLab
今天和师父还有孙老师一起,两位大神给我讲了下全世界最先进的云平台架构(Tigzx). 废话不多说,直接说代码的GitLab 第一步: 访问路径:http://git.dlanqi.com:30503, ...
- HDU 1016.Prime Ring Problem-素数环,相邻两数和为素数-DFS
Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- Linux的重定向与管道
(1).输出重定向 定义:将命令的标准输出结果保存到指定的文件中,而不是直接显示在显示器上. 输出重定向使用>和>>操作符. 语法:cmd > filename,表示将标准输出 ...
- Codeforces 724E Goods transportation(最小割转DP)
[题目链接] http://codeforces.com/problemset/problem/724/E [题目大意] 每个城市有pi的物品可以运出去卖,si个物品可以买, 编号小的城市可以往编号大 ...
- 【带权并查集】poj1182 食物链
带权并查集,或者叫做种类并查集,经典题. http://blog.csdn.net/shuangde800/article/details/7974668 这份代码感觉是坠吼的. 我的代码是暴力分类讨 ...
- 【深搜+set使用学习】POJ3050-Hopscotch
[题目大意] 给出一个5*5的方格,求出从任意一点出发走6步组成的不同序列数. [思路] dfs的水题,当作set使用方法的初次学习.每次从任意一点出发进行一次dfs,将序列加入set,最后输出set ...
- leetcode 576. Out of Boundary Paths
leetcode 576 题意大概就是在一个m*n的网格中,在坐标为[i,j]的网格上放一个物体,在规定时间N(t<=N)中,有多少种方法把物体移动出去.物体只能上下左右移动,一次移动一格,移动 ...
- kubernetes HA 脚本
集群方案: 发行版:CentOS 7 版本: Kubernetes:1.9.1 master高可用方案:keepalived LVS 网络方案:Flannel Master HA 四步骤: 1. 安装 ...
- NHibernate 之持久化类、拦截器 (第二篇)
一.持久化类中成员标量的要求 作为被NHibernate使用的持久化类,必须满足以下几点要求: 1.声明读写属性 在NHibernate的使用中,持久化类的成员变量必须声明对应的属性,NHiberna ...
- new placement 的使用
#include <iostream> #include "TModel.h" int main() { ]; std::cout<<"Sourc ...