Chrome DevTools Elements
Chrome DevTools Sources
Chrome DevTools Network
Chrome DevTools Timeline
Chrome DevTools Profiles
1. Minify and compress Javascript & CSS
2. Optimize images
3. Reduce HTTP requests
4. Caching
The fastest and best optimized resource is a resource not sent.
1. Concatenate JS/CSS files
2. Minify JS/CSS
3. Enable Gzip Compression
4. Use less JS/CSS
Web Performance Pt. N?
Web Performance Pt. N?
Chrome DevTools
https://developers.google.com/web/fundamentals/performance/critical-rendering-path/
Chrome DevTools
Async resources unblock the document parser and allow the browser to avoid blocking.
All CSS resources should be specified as early as possible within the HTML document such that the browser can discover the <link> tags and dispatch the request for the CSS as soon as possible.
https://aerotwist.com/blog/the-anatomy-of-a-frame/
1. Reduce the complexity of your selectors
2. Use a class-centric methodology like BEM
var $window = $( window ),
$document = $( document ),
$footer = $( '#footer' ),
$sidebar = $( '#sidebar' ),
$images = $( 'img' );
Layout Thrashing occurs when JavaScript violently writes, then reads, from the DOM, multiple times causing document reflows.
// Read
var h1 = element1.clientHeight;
// Write (invalidates layout)
element1.style.height = (h1 * 2) + 'px';
// Read (triggers layout)
var h2 = element2.clientHeight;
// Write (invalidates layout)
element2.style.height = (h2 * 2) + 'px';
// Read (triggers layout)
var h3 = element3.clientHeight;
// Write (invalidates layout)
element3.style.height = (h3 * 2) + 'px';
https://csstriggers.com/
Chrome DevTools Timeline
Chrome DevTools Paint Flashing
1.
2.
The Window.requestAnimationFrame() method schedules a function to be executed at the next frame
https://github.com/wilsonpage/fastdom
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);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
var myEfficientFn = debounce(function() {
// All the taxing stuff you do
}, 250);
window.addEventListener('resize', myEfficientFn);
Instead of changing styles, manipulate pre-defined CSS classes
Multi-threading :)
Cannot work with DOM :(
.our-element {
transform: translateZ(0);
}
.some-element {
will-change: transform;
}
.avoid-events {
pointer-events: none;
}
Web Performance Pt. N?
https://aerotwist.com/blog/the-cost-of-frameworks/
Avoid layout trashing
Page loading
Before | After |
~40 s | ~6 s |
Slideshow from WebPurple
Article, tools, videos and so on.
Google developers :)
Trello optimization experience