Slide 1

Slide 1 text

AUTOMATIZE FRONTEND OPTIMIZATIONS

Slide 2

Slide 2 text

Preparations

Slide 3

Slide 3 text

• I use gulp-load-plugins for loading Gulp plugins • it loads all gulp- plugins into an assigned variable • every time you see $.fooBar, think gulp-foo-bar

Slide 4

Slide 4 text

Concatenate & Compress CSS/JS/HTML

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

• gulp-useref • gulp-if • gulp-csso • gulp-uglify • gulp-minify-html

Slide 9

Slide 9 text

• beware of missing semicolons + self-invoking anonymous functions • properly configure HTML minifier

Slide 10

Slide 10 text

Optimize Images

Slide 11

Slide 11 text

gulp-cache & gulp-imagemin

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

• SVG optimization removes stuff, configure carefully • image processing is slow, so we’re using gulp-cache

Slide 14

Slide 14 text

Gzipping index.html.gz

Slide 15

Slide 15 text

gulp-gzip & gulp-size

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

• turn on gzipping on your server

Slide 18

Slide 18 text

Asset revisioning (a.k.a. cache-busting) main.css ⇝ main-098f6bcd.css

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

• gulp-rev & gulp-rev-replace • set these files’ caches to never expire • double-check if references in revved assets have also been updated

Slide 21

Slide 21 text

Responsive images

Slide 22

Slide 22 text

Ugh. http://bradfrost.com/blog/post/device-fatigue/

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

allows for fine-tuning and best results best for a few important photos repetitive time-consuming error-prone

Slide 25

Slide 25 text

gulp-responsive

Slide 26

Slide 26 text

faster and less error-prone updated images get resized automatically the code gets huge very quickly

Slide 27

Slide 27 text

Image sprites

Slide 28

Slide 28 text

css-sprite

Slide 29

Slide 29 text

Critical CSS http://iamthefold.com/

Slide 30

Slide 30 text

tl;dr • criticalCSS or critical • loadCSS • critical-path-css-tools

Slide 31

Slide 31 text

Remove Unused CSS

Slide 32

Slide 32 text

gulp-uncss

Slide 33

Slide 33 text

• fires up PhantomJS and extracts used styles • tricky with web apps, many elements are initially hidden • possible solution: run it on your pattern library • additional configuration may be needed

Slide 34

Slide 34 text

PageSpeed Analytics

Slide 35

Slide 35 text

psi

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Now For Something Different…

Slide 38

Slide 38 text

Meet AssetGraph npm install --global assetgraph-builder

Slide 39

Slide 39 text

assetgraph-builder

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

• just give it the root, it will do the rest • finds assets by following URLs • it has gajillion features (asset optimizations, spriting, image processing, revisioning, gzipping…)

Slide 42

Slide 42 text

Spriting

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

IE6-9 CSS Selector Limit (4095)

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Inline Small Background Images

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Image Processing

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

And A Lot More…

Slide 55

Slide 55 text

A Good Read • Improving Smashing Magazine’s Performance: A Case Study, Vitaly Friedman

Slide 56

Slide 56 text

Follow Me • github.com/silvenon • twitter.com/silvenon