https://www.youtube.com/watch?v=FEs2jgZBaQA&list=UUzoVCacndDCfGDf41P-z0iA
Ideally, you'd want a page speed score of:
- 85 for Mobile
- 90 for Desktop
Look for throttling in device emulation.
Accidental slowness is a problem many of us face.
Speed Index <= 1000ms
- Minify CSS (
gulp-cssmin
),cssshrink
- Minify HTML (
gulp-htmlmin
) - Minify JavaScript (
gulp-uglify
) - Optimize images (
gulp-imagemin
,gulp-svgmin
)
Benchmarks of css minifiers: http://goalsmashers.github.io/css-minification-benchmark/
http://i.imgur.com/E78GYAD.png
Audits -> Web Page Performance - CSS Styles http://i.imgur.com/sQycMYx.png
gulp-uncss
, http://i.imgur.com/0mVwbCe.png
http://i.imgur.com/Xkz0r5l.png
Source -> Sass -> CSS -> uncss -> minify -> deliver
Questionable. Really useful on larger sites.
Build-time styles & UI verification, useful for seeing if stuff changes after doing your uncss builds.
http://i.imgur.com/r6Jk6L3.png
Use PhantomCSS for regression css. CasperJS, PhantomJS, PhantomCSS.
Also: huxley, wraith, needle, csscritic, dpxdt
We want to display something almost instantly to give the effect that the page is fast.
One trick for this is to just render visible content.
- One RTT render for above the fold.
- Fast server response. No redirects
- Must optimize critical rendering path a. Inline critical CSS b. Remove any blocking JS
What do we really need to do?
- Extract stylesheets from HTML
- Choice of extraction or defining *.css files upfront
- Generate the above the fold CSS
- Decide on target viewports. Multiple? One sweet spot?
- Keep it small and lightweight: under 14 KB
- Inline critical-path CSS in
- Asychronously load the rest of your styles
- Remove them from the critical path
npm install critical
npm install criticalcss
npm install penthouse
How does critical work: http://i.imgur.com/DBYX4D6.png
http://i.imgur.com/M499ze2.png
critical
for gulp
http://i.imgur.com/720kAKW.png
- ImageOptim / Imagemin
- GIFBrewery
- Packed Image Diffs
- Run OSX screencapture every 0.1 secons
- Run
python anim_encoder.py folderName
over the ouput - Single packed png with diffs between frames. JS for turning png + json into animation
Good support for the element, smaller size than a gif!
http://i.imgur.com/phwy3YI.png
Can catch some really huge regressions that you implement.
npm install webpagetest
webpage test <url>
webpagetest test <url> --wait 8000
grunt perfbudget
"Someone regressed our performance budget"
npm install psi
-> page speed insights
grunt pagespeed
npm install phantomas
Easiest way to keep your CSS maintanable is to minimize repetition. (or not write it in the first place)
npm install colorguard
-> tells you about collisions between colors
npm install parker
-> tells you about duplicate selectors, media queries, etc
StyleStats (website)
- Don't guess it, test it
- Measure, optimize & repeat
- Validate your optimizations. Make sure output is ~1:1
- Set a performance budget
- Set goals. Automate performance measurement.
- Focus on what matters to your users
Consider using a 'build' step that goes through your generated sources and cleans them up.