This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="module"> | |
// Load the web-vitals library from unpkg.com (or host locally): | |
import {getFCP, getLCP, getCLS, getTTFB, getFID} from 'https://unpkg.com/web-vitals?module'; | |
function getSelector(node, maxLen = 100) { | |
let sel = ''; | |
try { | |
while (node && node.nodeType !== 9) { | |
const part = node.id ? '#' + node.id : node.nodeName.toLowerCase() + ( | |
(node.className && node.className.length) ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function web_vitals( ){ | |
// The Data (LCP, CLS and FID) collected by web-vitals.js are not sent to Google Analytics but display on console tab. | |
//You will only see it if you're login user | |
if ( is_user_logged_in() ){ | |
?> | |
<script type="module"> | |
import {getCLS, getFID, getLCP} from 'https://unpkg.com/web-vitals?module'; | |
getCLS(console.log); | |
getFID(console.log); | |
getLCP(console.log); |
OlderNewer