Slide 1

Slide 1 text

@onishiweb Best viewed with… Adam Onishi ThemeConf - September 2015

Slide 2

Slide 2 text

@onishiweb Good Morning!

Slide 3

Slide 3 text

@onishiweb adamonishi.com twitter.com/onishiweb github.com/onishiweb speakerdeck.com/onishiweb

Slide 4

Slide 4 text

@onishiweb @onishiweb

Slide 5

Slide 5 text

@onishiweb A long time ago…

Slide 6

Slide 6 text

@onishiweb

Slide 7

Slide 7 text

@onishiweb “Browser wars!”

Slide 8

Slide 8 text

@onishiweb @onishiweb

Slide 9

Slide 9 text

@onishiweb Fast-forward to today…

Slide 10

Slide 10 text

@onishiweb – a “modern” website “For best results view this page in Chrome.”

Slide 11

Slide 11 text

@onishiweb

Slide 12

Slide 12 text

@onishiweb Chrome Firefox IE Safari Opera UC Browser Safari (iOS) Opera Mini Android Browser Amazon Silk YaBrowser Maxthon Iron Nokia Browser Sea Monkey Avant Camino Epiphany OmniWeb Konqueror Galeon Swiftfox Edge

Slide 13

Slide 13 text

@onishiweb Chrome (v44) • Cache.add() • Request.context() • Notification.data Edge • img srcset • CSS Regions • Arrow functions Firefox (v40) • Improved Dev tools • IndexedDB transactions • Fetch API (v39) Safari (v9) • Backdrop filters • CSS scroll snapping • Content blocking

Slide 14

Slide 14 text

@onishiweb

Slide 15

Slide 15 text

@onishiweb A moratorium http://www.quirksmode.org/blog/archives/2015/07/stop_pushing_th.html

Slide 16

Slide 16 text

@onishiweb Developer-first development

Slide 17

Slide 17 text

@onishiweb Cake or Death?

Slide 18

Slide 18 text

@onishiweb Progressive Enhancement

Slide 19

Slide 19 text

@onishiweb “Vague, but exciting”

Slide 20

Slide 20 text

@onishiweb @onishiweb Photo by Simon Collison - https://flic.kr/p/pbRdFm

Slide 21

Slide 21 text

@onishiweb @onishiweb Photo by Pedro Ribeiro Simões - https://flic.kr/p/bvCA8

Slide 22

Slide 22 text

@onishiweb The Web JS CSS HTML Internet

Slide 23

Slide 23 text

@onishiweb Chrome Firefox IE Safari Opera UC Browser Safari (iOS) Opera Mini Android Browser Amazon Silk YaBrowser Maxthon Iron Nokia Browser Sea Monkey Avant Camino Epiphany OmniWeb Konqueror Galeon Swiftfox Edge

Slide 24

Slide 24 text

@onishiweb – Paul Robert Lloyd “By making fewer assumptions about context and interface, focusing more on users’ tasks and goals, we can create more adaptable products.” http://alistapart.com/article/thinking-responsively-a-framework-for-future-learning

Slide 25

Slide 25 text

@onishiweb @onishiweb Photo from EdgeConf 2015

Slide 26

Slide 26 text

@onishiweb – Jake Archibald “Every phase of the enhancement absolutely must have a real user” http://www.fivesimplesteps.com/products/modern-progressive-enhancement

Slide 27

Slide 27 text

@onishiweb Performance

Slide 28

Slide 28 text

@onishiweb Average web page >2Mb http://httparchive.org/interesting.php?a=All&l=May%2015%202015

Slide 29

Slide 29 text

@onishiweb Progressive performance

Slide 30

Slide 30 text

@onishiweb @onishiweb

Slide 31

Slide 31 text

@onishiweb Polyfills

Slide 32

Slide 32 text

@onishiweb – Christian Heilmann “The love we give [old browsers] is really bordering on necrophilia at times.”

Slide 33

Slide 33 text

@onishiweb Progressive Performance

Slide 34

Slide 34 text

@onishiweb CSS

Slide 35

Slide 35 text

@onishiweb CSS is still an enhancement

Slide 36

Slide 36 text

@onishiweb CSS blocks rendering

Slide 37

Slide 37 text

@onishiweb

Slide 38

Slide 38 text

@onishiweb Critical Path CSS

Slide 39

Slide 39 text

@onishiweb Photo of Patrick at FEL (if possible) @onishiweb Photo from FEL One Day - https://flic.kr/p/gRzhY2

Slide 40

Slide 40 text

@onishiweb How?

Slide 41

Slide 41 text

@onishiweb @onishiweb https://github.com/addyosmani/critical

Slide 42

Slide 42 text

@onishiweb @onishiweb https://github.com/pocketjoso/penthouse

Slide 43

Slide 43 text

@onishiweb gulp.task('critical', function () { penthouse({ url : 'http://localhost:8000/index.html', css : 'public/styles.css', width : 720, // viewport width height : 500 // viewport height }, function(err, criticalCss) { if (err) { // handle error console.log('error', err); } fs.writeFileSync('public/critical.css', criticalCss); }); });

Slide 44

Slide 44 text

@onishiweb loadCSS https://github.com/filamentgroup/loadCSS/

Slide 45

Slide 45 text

@onishiweb Progressively enhancing CSS delivery

Slide 46

Slide 46 text

@onishiweb Images

Slide 47

Slide 47 text

@onishiweb http://httparchive.org/interesting.php?a=All&l=May%2015%202015

Slide 48

Slide 48 text

@onishiweb @onishiweb

Slide 49

Slide 49 text

@onishiweb

Slide 50

Slide 50 text

@onishiweb , srcset & size

Slide 51

Slide 51 text

@onishiweb https://www.youtube.com/watch?v=WwgQ0LGRnR8

Slide 52

Slide 52 text

@onishiweb

Slide 53

Slide 53 text

@onishiweb Progressively enhancing image delivery

Slide 54

Slide 54 text

@onishiweb Picture http://caniuse.com/#feat=picture

Slide 55

Slide 55 text

@onishiweb srcset & sizes http://caniuse.com/#feat=srcset

Slide 56

Slide 56 text

@onishiweb Fonts

Slide 57

Slide 57 text

@onishiweb We ❤ web fonts

Slide 58

Slide 58 text

@onishiweb

Slide 59

Slide 59 text

@onishiweb

Slide 60

Slide 60 text

@onishiweb Typekit asynchronous font loading

Slide 61

Slide 61 text

@onishiweb What about FOUT & FOIT?

Slide 62

Slide 62 text

@onishiweb 3s 3s 3s ∞ -

Slide 63

Slide 63 text

@onishiweb Developers need control

Slide 64

Slide 64 text

@onishiweb Font loading API

Slide 65

Slide 65 text

@onishiweb var f = new FontFace("open_sansbold", "url(/fonts/opensans-bold- webfont.woff)", {}); f.load().then(function (loadedFace) { document.fonts.add(loadedFace); document.body.style.fontFamily = "open_sansbold, serif"; });

Slide 66

Slide 66 text

@onishiweb var f = new FontFace("open_sansbold", "url(/fonts/opensans-bold- webfont.woff)", {}); f.load().then(function (loadedFace) { document.body.className += ' fonts—loaded'; }); /* CSS */ p { visibility: hidden; } .fonts-loaded p { visibility: visible; }

Slide 67

Slide 67 text

@onishiweb Progressively enhancing font loading

Slide 68

Slide 68 text

@onishiweb Font loading API http://caniuse.com/#feat=font-loading

Slide 69

Slide 69 text

@onishiweb CSS Font Rendering http://tabatkins.github.io/specs/css-font-rendering/

Slide 70

Slide 70 text

@onishiweb CSS Font Rendering

Slide 71

Slide 71 text

@onishiweb JavaScript

Slide 72

Slide 72 text

@onishiweb The Web JS CSS HTML Internet

Slide 73

Slide 73 text

@onishiweb Cutting the mustard http://responsivenews.co.uk/post/18948466399/cutting-the-mustard

Slide 74

Slide 74 text

@onishiweb ES2015

Slide 75

Slide 75 text

@onishiweb The “other” problem

Slide 76

Slide 76 text

@onishiweb – Peter Herlihy, GDS Team “1.1% of people aren’t getting JavaScript enhancements (1 in 93).”

Slide 77

Slide 77 text

@onishiweb @onishiweb http://kryogenix.org/code/browser/everyonehasjs.html

Slide 78

Slide 78 text

@onishiweb @onishiweb

Slide 79

Slide 79 text

@onishiweb – Jeremy Keith “Brilliant easter egg in the newly- redesigned nasa.gov — if JavaScript fails, you are immersed in the experience of deep space”

Slide 80

Slide 80 text

@onishiweb @onishiweb

Slide 81

Slide 81 text

@onishiweb The rise of the frameworks

Slide 82

Slide 82 text

@onishiweb

Slide 83

Slide 83 text

@onishiweb Is there a better way?

Slide 84

Slide 84 text

@onishiweb Universal JavaScript

Slide 85

Slide 85 text

@onishiweb Server Side rendering with Node.js

Slide 86

Slide 86 text

@onishiweb How?

Slide 87

Slide 87 text

@onishiweb ReactJS

Slide 88

Slide 88 text

@onishiweb React.renderToString();

Slide 89

Slide 89 text

@onishiweb app.get('/', function(req, res){ // React.renderToString takes your component // and generates the markup ReactApp = React.createFactory( require(‘../components/index.js') ); reactHtml = React.renderToString( ReactApp({}) ); // Output html rendered by react res.render('index.ejs', { reactOutput: reactHtml }); });

Slide 90

Slide 90 text

@onishiweb GoCardless

Slide 91

Slide 91 text

@onishiweb – Jack Franklin, GoCardless “If you visit it in a ‘good’ browser with JS on, you get an incredibly snappy React app, if not, you hit the server on every click.”

Slide 92

Slide 92 text

@onishiweb Progressively enhancing JavaScript frameworks

Slide 93

Slide 93 text

@onishiweb Control

Slide 94

Slide 94 text

@onishiweb @onishiweb

Slide 95

Slide 95 text

@onishiweb The Network

Slide 96

Slide 96 text

@onishiweb The Web JS CSS HTML Internet

Slide 97

Slide 97 text

@onishiweb Do we always have access to the network?

Slide 98

Slide 98 text

@onishiweb Mobile connections

Slide 99

Slide 99 text

@onishiweb Cake or Death?

Slide 100

Slide 100 text

@onishiweb Enter Service Worker

Slide 101

Slide 101 text

@onishiweb The web is going offline!

Slide 102

Slide 102 text

@onishiweb How?

Slide 103

Slide 103 text

@onishiweb Register service worker Cache content Connect to network Request Page load Usable website

Slide 104

Slide 104 text

@onishiweb Go to network Service worker intercepts Check cache Request Page load Usable website Get content

Slide 105

Slide 105 text

@onishiweb if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/worker.js') .then(function(registration) { // Registration was successful console.log('ServiceWorker registered: ', registration.scope); }) .catch(function(err) { // registration failed :( console.log('ServiceWorker registration failed: ', err); }); }

Slide 106

Slide 106 text

@onishiweb self.addEventListener('install', function(event) { // Perform install steps event.waitUntil( caches.open(‘content-cache-v1').then(function(cache) { return cache.addAll([ '/index.html', '/css/main.min.css', '/main.js' ]); }) ) });

Slide 107

Slide 107 text

@onishiweb Register service worker Cache content Connect to network Request Page load Usable website

Slide 108

Slide 108 text

@onishiweb self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request) .then(function(response) { // Cache hit - return response if (response) { return response; } return fetch(event.request); } ) ); });

Slide 109

Slide 109 text

@onishiweb

Slide 110

Slide 110 text

@onishiweb @onishiweb https://jakearchibald.com/2014/offline-cookbook/

Slide 111

Slide 111 text

@onishiweb Caveats (a few things to be aware of)

Slide 112

Slide 112 text

@onishiweb Development flow https://www.chromium.org/blink/serviceworker/getting-started#TOC-Development-flow

Slide 113

Slide 113 text

@onishiweb @onishiweb chrome://inspect/#service-workers

Slide 114

Slide 114 text

@onishiweb @onishiweb chrome://serviceworker-internals/

Slide 115

Slide 115 text

@onishiweb HTTPS only

Slide 116

Slide 116 text

@onishiweb – MDN “Having modified network requests wide open to man in the middle attacks would be really bad.”

Slide 117

Slide 117 text

@onishiweb How much can I cache?

Slide 118

Slide 118 text

@onishiweb Progressively enhancing the network

Slide 119

Slide 119 text

@onishiweb Browser support…

Slide 120

Slide 120 text

@onishiweb Service Worker http://caniuse.com/#feat=serviceworkers

Slide 121

Slide 121 text

@onishiweb Fetch API http://caniuse.com/#feat=fetch

Slide 122

Slide 122 text

@onishiweb Caches https://jakearchibald.github.io/isserviceworkerready/#caches

Slide 123

Slide 123 text

@onishiweb @onishiweb https://jakearchibald.github.io/isserviceworkerready/

Slide 124

Slide 124 text

@onishiweb Progressive Performance

Slide 125

Slide 125 text

@onishiweb Critical Path CSS Responsive Images Font Loading API Universal JavaScript Service Workers

Slide 126

Slide 126 text

@onishiweb @onishiweb https://github.com/onishiweb/progressive-performance

Slide 127

Slide 127 text

@onishiweb Return of the browser wars

Slide 128

Slide 128 text

@onishiweb No…

Slide 129

Slide 129 text

@onishiweb – William Gibson “The future is already here - it’s just not very evenly distributed.”

Slide 130

Slide 130 text

@onishiweb Thanks Adam Onishi ThemeConf - September 2015