Skip to content

Instantly share code, notes, and snippets.

@danieltxok
danieltxok / CLS.js
Created February 17, 2021 11:20
CLS Bookmarklet
javascript:
(function(){
try {
let cls = 0;
const canvas = document.createElement('canvas');
canvas.style.width = '100%';
canvas.style.height = '100%';
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.style.position = 'absolute';
@danieltxok
danieltxok / LCP.js
Created February 17, 2021 11:21
LCP Bookmarklet
javascript:
new PerformanceObserver((entryList)=>{
for (const entry of entryList.getEntries()) {
let consoleGroup = `%cLCP candidate: ${Math.round(entry.startTime)}ms`;
let styles = '';
if (entry.startTime >= 2500) {
styles = 'color: red;';
}
console.group(consoleGroup, styles);
console.log('Element:', entry.element);
@danieltxok
danieltxok / FID.js
Created February 17, 2021 11:22
FID Bookmarklet
javascript:
new PerformanceObserver((entryList)=>{
for (const entry of entryList.getEntries()) {
const delay = entry.processingStart - entry.startTime;
let consoleGroup = `%cFID value: ${Math.round(delay)}ms`;
let styles = '';
if (delay >= 100) {
styles = 'color: red;';
}
console.group(consoleGroup, styles);
@danieltxok
danieltxok / Clean.js
Created February 17, 2021 11:58
Deletes previous page load
javascript:
document.documentElement.innerHTML = '';
for (const obj of [document, window]) {
for (const event of Object.values(getEventListeners(obj))) {
for (const {type, listener, useCapture} of event) {
obj.removeEventListener(type, listener, useCapture)
}
}
}
console. clear();