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() { | |
'use strict'; | |
// First paint perf. | |
if (window.chrome && window.chrome.loadTimes) { | |
const getFP = function() { | |
let load = chrome.loadTimes(); | |
let fp = (load.firstPaintTime - load.startLoadTime) * 1000; | |
return Math.round(fp); | |
}; |
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
Now at https://github.com/ebidel/puppeteer-examples/blob/master/lighthouse/throttling.js |
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
Moved to https://github.com/ebidel/puppeteer-examples/blob/master/lighthouse/chromelauncher_puppeteer.js |
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
Moved to https://github.com/ebidel/puppeteer-examples/blob/master/monitor_internet_connection.js |
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
// ES6 meta programming ??? | |
// The more complex form of ES6 template strings are called | |
// "tagged" template strings. In short, they allow you to | |
// pass the final evaluated string to a function for further | |
// processing. This allows for some interesting things. For example: | |
// | |
// get`https://api.github.com/repos/${org}/${repo}/issues?sort=${sort}`; | |
// | |
// _could_ make a network request and return a Promise with the result |
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
// Continuously higlights the custom elements on the page. This is useful | |
// if new custom elements are lazy loaded later on or you have a SPA | |
// that uses other elements. | |
// CE finding code from: https://gist.github.com/ebidel/4bdbe9db55d8a775d0a4 | |
(function() { | |
let cache = []; | |
function highlightCustomElements() { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Abort promises</title> | |
</head> | |
<body> | |
<button class="download">download</button> | |
<button class="abort">abort</button> |
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() { | |
const scroller = document.scrollingElement || document.body; | |
// Smooth scrolls to the bottom of the page. | |
window.smoothScrollPage = (y = scroller.scrollHeight) => { | |
scroller.style.scrollBehavior = 'smooth'; | |
scroller.scrollTop = y; | |
scroller.style.scrollBehavior = ''; | |
}; |
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
/** | |
* @author ebidel@ (Eric Bidelman) | |
* License Apache-2.0 | |
*/ | |
// Drop this in the DevTools console: | |
(new ReportingObserver((reports, observer) => { | |
console.warn('This page is using deprecated APIs or features:'); | |
const deprecations = reports.map(report => { |
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
javascript:(function(){function isUnregisteredCustomElement(el){if(el.constructor==HTMLElement){console.error("Found unregistered custom element:",el);return true;}return false;}function isCustomEl(el){return el.localName.indexOf('-')!=-1||el.getAttribute('is');}var allCustomElements=document.querySelectorAll('html /deep/ *');allCustomElements=Array.prototype.slice.call(allCustomElements).filter(function(el){return isCustomEl(el);});var foundSome=false;for(var i=0,el;el=allCustomElements[i];++i){if(isUnregisteredCustomElement(el)){foundSome=true;}}if(foundSome){alert('Oops: found one or more unregistered custom elements in use! Check the console.');}else{alert('Good: All custom elements are registered :)');}})(); |