This file contains hidden or 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 regex = /t(e)(st(\d?))/g; | |
const result = 'test1test2'.match(regex); | |
console.log(result); // ['test1', 'test2'] |
This file contains hidden or 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
// Styles | |
@media screen and (min-width: 769px) { | |
.mobile-layout { | |
display: none; | |
} | |
} | |
@media screen and (max-width: 768px) { | |
.desktop-layout { | |
display: none; |
This file contains hidden or 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
// Server | |
const uaParser = require('ua-parser-js'); | |
const userAgent = uaParser(req.headers['user-agent']); | |
const { type } = userAgent.getDevice(); | |
const html = ReactDOMServer.renderToString( | |
<DeviceContext.Provider type={{ type }}> | |
<App /> | |
</DeviceContext.Provider> |
This file contains hidden or 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
// Styles | |
.layout { | |
width: 80vh; | |
} | |
@media screen and (max-width: 768px) { | |
.layout { | |
width: 100vh; | |
} | |
} |
This file contains hidden or 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
[ | |
{ | |
url: 'https://pptr.dev/', | |
type: 'js', | |
usedBytes: 149, | |
totalBytes: 150 | |
}, | |
{ | |
url: 'https://www.googletagmanager.com/gtag/js?id=UA-106086244-2', | |
type: 'js', |
This file contains hidden or 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
{ | |
"traceEvents":[ | |
{ | |
"pid": 21975, | |
"tid": 38147, | |
"ts": 17376402124, | |
"ph": "X", | |
"cat": "toplevel", | |
"name": "MessageLoop::RunTask", | |
"args": { |
This file contains hidden or 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(); | |
// Starts to record a trace of the operations | |
await page.tracing.start({ path: 'trace.json' }); | |
await page.goto('https://pptr.dev'); |
This file contains hidden or 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
{ | |
Timestamp: 6400.768827, // When the metrics were taken | |
Documents: 13, // Number of documents | |
Frames: 7, // Number of frames | |
JSEventListeners: 33, // Number of events | |
Nodes: 51926, // Number of DOM elements | |
LayoutCount: 6, // Number of page layouts | |
RecalcStyleCount: 13, // Number of page style recalculations | |
LayoutDuration: 0.545877, // Total duration of all page layouts | |
RecalcStyleDuration: 0.011856, // Total duration of all page style recalculations |
This file contains hidden or 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(); | |
await page.goto('https://pptr.dev'); | |
await page.waitForSelector('title'); | |
// Returns runtime metrics of the page |
This file contains hidden or 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
{ | |
timeOrigin: 1562785571340.2559, | |
timing: { | |
navigationStart: 1562785571340, | |
unloadEventStart: 0, | |
unloadEventEnd: 0, | |
redirectStart: 0, | |
redirectEnd: 0, | |
fetchStart: 1562785571340, | |
domainLookupStart: 1562785571347, |