Mark Lozano
Senior Software Developer @atlassian working on @trello
A request being queued indicates that:
Time the request spent waiting before it could be sent. It can be waiting for any of the reasons described for Queueing. Additionally, this time is inclusive of any time spent in proxy negotiation.
Time spent negotiating with a proxy server connection.
Time spent performing the DNS lookup. Every new domain on a page requires a full roundtrip to do the DNS lookup.
Time it took to establish a connection, including TCP handshakes/retries and negotiating a SSL.
Time spent completing a SSL handshake.
Time spent issuing the network request. Typically a fraction of a millisecond.
Time spent waiting for the initial response, also known as the Time To First Byte. This time captures the latency of a round trip to the server in addition to the time spent waiting for the server to deliver the response.
Time spent receiving the response data.
Google.com: +500 ms (speed decrease) -> -20% traffic loss
Yahoo.com: +400 ms (speed decrease) -> -5-9% full-page traffic loss (visitor left before the page finished loading)
Amazon.com: +100 ms (speed decrease) -> -1% sales loss
Combine external CSS and JS
Enable gzip compression ( Apache, Node, WordPress )
Compress images
Leverage Browser Caching
Put CSS in document head
Unused CSS rules ( Old CSS that can be pruned )
const start = new Date().getTime();
// Do some work...
const end = new Date().getTime();
const time = end - start;
performance.mark('start');
// Do some work...
performance.mark('end');
performance.measure('Our Measurement', 'start', 'end');
performance.getEntriesByType('measure');
<img src="large.jpg" />
<img srcset="large.jpg, 800w" />
<img
srcset="small.jpg 300w,
medium.jpg 800w,
large.jpg, 1200w"
/>
(with fallback)
<img
src="large.jpg"
srcset="small.jpg 300w,
medium.jpg 800w,
large.jpg, 1200w"
/>
Most devices today refresh their screens 60 times a second. The browser needs to match the device’s refresh rate and put up 1 new picture, or frame, for each of those screen refreshes.
Each of those frames has a budget of just over 16ms (1 second / 60 = 16.66ms). In reality, however, the browser has housekeeping work to do, so all of your work needs to be completed inside 10ms.
function foo() {
bar = "This is probably not what you meant";
}
const data = getData();
setInterval(() => {
document.body.innerHTML = JSON.stringify(data);
}, 1000);
const button = document.getElementById("button");
// Then Later
function removeButton() {
document.body.removeChild(
document.getElementById("button")
);
}
By Mark Lozano