Device Refresh Rates
Device Refresh Rates
The Pixel Pipeline
The Pixel Pipeline
The Pixel Pipeline
The Pixel Pipeline
The Pixel Pipeline
The Pixel Pipeline
The Pixel Pipeline
The Pixel Pipeline
The Pixel Pipeline
csstriggers.com
Javascript Optimization
Javascript Optimization
Javascript Optimization
const adiv = document.getElementById('mydiv');
let leftpos = 0;
setInterval(() => {
leftpos += 5;
adiv.style.left = leftpos + 'px';
}, 50)
Javascript Optimization
const adiv = document.getElementById('mydiv');
let leftpos = 0;
let prevMoveTime = 0;
function move(time) => {
leftpos += 5;
adiv.style.left = leftpos + 'px';
requestAnimationFrame(move);
}
requestAnimationFrame(move);
Javascript Optimization
Javascript Optimization
Javascript Optimization
const taskList = breakBigTaskIntoMicroTasks(largeList);
requestAnimationFrame(processTaskList);
function processTaskList(taskStartTime) {
let taskFinishTime;
do {
// Assume the next task is pushed onto a stack.
const nextTask = taskList.pop();
// Process nextTask.
processTask(nextTask);
// Go again if there’s enough time to do the next task.
taskFinishTime = window.performance.now();
} while (taskFinishTime - taskStartTime < 3);
if (taskList.length > 0) {
requestAnimationFrame(processTaskList);
}
}
Javascript Optimization
Javascript Optimization
Style Optimization
Style Optimization
Style Optimization
Style Optimization
<div class="table">
<div class="row header">
<span class="blue">
Title
</span>
</div>
<div class="row body">
<span class="blue">
Body text
</span>
</div>
</div>
.table {
font-size: 12px;
border: 1px solid black;
}
.row, .row.header {
color: red;
}
.header {
font-size: 15px;
}
.body {
text-decoration: underline;
}
.blue {
color: blue;
}
Style Optimization
Style Optimization
.box:nth-last-child(-n+1) .title {
/* styles */
}
Style Optimization
.box:nth-last-child(-n+1) .title {
/* styles */
}
.final-box-title {
/* styles */
}
Style Optimization
.box:nth-last-child(-n+1) .title {
/* styles */
}
.final-box-title {
/* styles */
}
Style Optimization
Style Optimization
Layout Optimization
Layout Optimization
Layout Optimization
Layout Optimization
.box {
width: 20px;
height: 20px;
}
/**
* Changing width and height
* triggers layout.
*/
.box--expanded {
width: 200px;
height: 350px;
}
Layout Optimization
.box {
width: 20px;
height: 20px;
}
/**
* Changing width and height
* triggers layout.
*/
.box--expanded {
width: 200px;
height: 350px;
}
Layout Optimization
Layout Optimization
Layout Optimization
Layout Optimization
Paint Optimization
Paint Optimization
Paint Optimization
Paint Optimization
Paint Optimization
Paint Optimization
Paint Optimization
.moving-element {
will-change: transform;
}
Paint Optimization
Compositor
Compositor
TL;DR
TL;DR
TL;DR
TL;DR
TL;DR
TL;DR