View lighthouse-user-flow.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
const puppeteer = require('puppeteer'); | |
const { startFlow } = require('lighthouse/lighthouse-core/fraggle-rock/api.js'); | |
const fs = require("fs"); | |
(async () => { | |
const browser = await puppeteer.launch({ headless: false }); | |
const page = await browser.newPage(); | |
const flow = await startFlow(page, { | |
name: 'Go to homepage', |
View github-search.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
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
async function waitForSelectors(selectors, frame) { | |
for (const selector of selectors) { | |
try { | |
return await waitForSelector(selector, frame); |
View debugbear-helper-functions.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
var waitFor = async function waitFor(conditionFn, { timeout = 15000, checkInterval = 25, debugString = null, } = {}) { | |
if (typeof conditionFn !== "function") { | |
throw Error("waitFor condition argument isn't a function. Did you mean waitForElement?"); | |
} | |
if (!debugString) { | |
debugString = conditionFn.toString(); | |
} | |
let startedAt = new Date(); | |
let conditionResult = await conditionFn(); | |
while (!conditionResult) { |
View debounce.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
function debounce(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; | |
if (!immediate) func.apply(context, args); | |
}; | |
var callNow = immediate && !timeout; | |
clearTimeout(timeout); |
View throttle.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
function throttle (callback, limit) { | |
var wait = false; | |
return function () { | |
if (!wait) { | |
callback.apply(null, arguments); | |
wait = true; | |
setTimeout(function () { | |
wait = false; | |
}, limit); | |
} |
View More info on Chrome extension performance
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
- |
View sw.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
self.addEventListener("install", async e => { | |
caches.open("v1").then(function (cache) { | |
return cache.addAll(["/app", "/app.css"]); | |
}); | |
}); | |
self.addEventListener("fetch", event => { | |
event.respondWith( | |
caches.match(event.request).then(cachedResponse => { | |
return cachedResponse || fetch(event.request); |
NewerOlder