Designing for Everyone: Building Great Web Experiences for Any Device

A presentation at Microsoft Build 2018 in May 2018 in Seattle, WA, USA by Aaron Gustafson

Slide 1

Slide 1

Designing for Everyone: 
 Building Great Web Experiences 
 for Any Device Aaron Gustafson BRK2411

Slide 2

Slide 2

In October of 2016, mobile ate the desktop…

Slide 3

Slide 3

https://aka.ms/desktop-v-mobile-2016 Mobile traffic overtakes desktop globally

Slide 4

Slide 4

Mobile accounts for 56% of all traffic* Desktop Mobile *Based on 77 billion website visits. https://aka.ms/desktop-web-2017

Slide 5

Slide 5

But the numbers differ by industry News Desktop Mobile Food Desktop Mobile Finance Desktop Mobile https://aka.ms/desktop-web-2017

Slide 6

Slide 6

Desktop users spend more time on sites (60%)* Desktop Mobile *Based on 39 trillion seconds. https://aka.ms/desktop-web-2017

Slide 7

Slide 7

Anywhere from 10-300% Finance Desktop Mobile Food Desktop Mobile News Desktop Mobile https://aka.ms/desktop-web-2017

Slide 8

Slide 8

Bounce rates on mobile are 40% higher than desktop* 0 11 22 33 44 Desktop Mobile *Based on 584 billion page views. https://aka.ms/desktop-web-2017

Slide 9

Slide 9

Desktop users view more pages (59%) Desktop Mobile *Based on 584 billion page views. https://aka.ms/desktop-web-2017

Slide 10

Slide 10

Anywhere from 1.5x to 3x more pages per visit Finance Desktop Mobile Food Desktop Mobile News Desktop Mobile https://aka.ms/desktop-web-2017

Slide 11

Slide 11

The “desktop” experience matters

Slide 12

Slide 12

Web browsing is 
 the #1 user activity 
 on PCs

Slide 13

Slide 13

The “desktop” experience matters, 
 even for Progressive Web Apps

Slide 14

Slide 14

40% of Order Ahead transactions on the Starbucks PWA come from desktop

Slide 15

Slide 15

Carnival Cruise Line saw a 16% opt-in 
 for Push Notifications 
 on desktop Katarzyna Ostrowska https://aka.ms/carnival-pwa

Slide 16

Slide 16

We believe the web can (and should) reach 
 beyond the browser, which is why we are so heavily invested in making PWAs successful on Windows

Slide 17

Slide 17

PWAs start with a great web experience and then enhance that experience for performance, resilience, installation, and engagement

Slide 18

Slide 18

PWAs start with a great web experience and then enhance that experience for performance, resilience, installation, and engagement

Slide 19

Slide 19

PWAs start with a great web experience and then enhance that experience for performance, resilience, installation, and engagement

Slide 20

Slide 20

Progressive 
 / prəˈɡresiv/ 
 
 happening or developing gradually or in stages; proceeding step by step

Slide 21

Slide 21

Step 1 
 Focus on what matters

Slide 22

Slide 22

Consider forbes.com circa 2007

Slide 23

Slide 23

“Mobile first” thinking

Slide 24

Slide 24

Remember that text is the first interface

Slide 25

Slide 25

Is there anything missing that would 
 help users be more successful?

Slide 26

Slide 26

Finding Our Focus Josh Williams 
 Starbucks

Slide 27

Slide 27

Ta s k f i r s t ? Turns out customers like to “do” things with the apps we build

Slide 28

Slide 28

We focused on our 
 key customer journeys · Enable customers to join the Starbucks Rewards program · Enable customers to transact via Order Ahead and Barcode Pay · Enable customers to track 
 progress towards their 
 earned rewards

Slide 29

Slide 29

Store Locator was our first actual production “PWA” feature And it was chromed in the previous site

Slide 30

Slide 30

From there, we were able to 
 add in other key features · Sign-in and Account Create · Barcode pay · eGift and Account management · etc.

Slide 31

Slide 31

Slide 32

Slide 32

Finding Our Focus Josh Williams 
 Starbucks

Slide 33

Slide 33

Step 2 
 Use markup that supports the core experience

Slide 34

Slide 34

The words we choose matter, 
 but the markup we use matters equally

Slide 35

Slide 35

What does it mean?

<div class=&#34;entry&#34;> 
 <div class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</div> 
 <div class=&#34;entry__meta&#34;> 
 <div><b>Published</b> 24 May 2017</div> 
 <div><b>Reading Time</b> 25 minutes</div> 
 </div> 
 <div class=&#34;entry__content&#34;> 
 I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 
 </div>

Slide 36

Slide 36

This div marks up a piece of self-contained content

<div class=&#34;entry&#34;> 
 <div class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</div> 
 <div class=&#34;entry__meta&#34;> 
 <div><b>Published</b> 24 May 2017</div> 
 <div><b>Reading Time</b> 25 minutes</div> 
 </div> 
 <div class=&#34;entry__content&#34;> 
 I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 
 </div>

Slide 37

Slide 37

There’s a tag for that: article

<article class=&#34;entry&#34;> 
 <div class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</div> 
 <div class=&#34;entry__meta&#34;> 
 <div><b>Published</b> 24 May 2017</div> 
 <div><b>Reading Time</b> 25 minutes</div> 
 </div> 
 <div class=&#34;entry__content&#34;> 
 I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 
 </article>

Slide 38

Slide 38

This div is the title of the blog post

<article class=&#34;entry&#34;> 
 <div class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</div> 
 <div class=&#34;entry__meta&#34;> 
 <div><b>Published</b> 24 May 2017</div> 
 <div><b>Reading Time</b> 25 minutes</div> 
 </div> 
 <div class=&#34;entry__content&#34;> 
 I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 
 </article>

Slide 39

Slide 39

There’s a tag for that: h1

h6

<article class=&#34;entry&#34;> 
 <h1 class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</h1> 
 <div class=&#34;entry__meta&#34;> 
 <div><b>Published</b> 24 May 2017</div> 
 <div><b>Reading Time</b> 25 minutes</div> 
 </div> 
 <div class=&#34;entry__content&#34;> 
 I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 
 </article>

Slide 40

Slide 40

These div elements define various properties of the post

<article class=&#34;entry&#34;> 
 <h1 class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</h1> 
 <div class=&#34;entry__meta&#34;> 
 <div><b>Published</b> 24 May 2017</div> 
 <div><b>Reading Time</b> 25 minutes</div> 
 </div> 
 <div class=&#34;entry__content&#34;> 
 I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 
 </article>

Slide 41

Slide 41

There’s an element for the: dl

<article class=&#34;entry&#34;> 
 <h1 class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</h1> 
 <dl class=&#34;entry__meta&#34;> 
 <dt>Published</dt> <dd>24 May 2017</dd> 
 <dt>Reading Time</dt> <dd>25 minutes</dd> 
 </dl> 
 <div class=&#34;entry__content&#34;> 
 I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 
 </article>

Slide 42

Slide 42

Bonus: time

<article class=&#34;entry&#34;> 
 <h1 class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</h1> 
 <dl class=&#34;entry__meta&#34;> 
 <dt>Published</dt> <dd><time>24 May 2017</time></dd> 
 <dt>Reading Time</dt> <dd>25 minutes</dd> 
 </dl> 
 <div class=&#34;entry__content&#34;> 
 I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 
 </article>

Slide 43

Slide 43

Bonus: time <time datetime=&#34;2017-05-24&#34;> 
 24 May 2017</time> 
 
 <time datetime=&#34;2017-05-24T11:13:24&#34;> 
 24 May 2017</time> 
 
 <time datetime=&#34;2017-05-24T11:13:24-04:00&#34;> 
 24 May 2017</time>

Slide 44

Slide 44

This is “flow” content with line breaks

<article class=&#34;entry&#34;> 
 <h1 class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</h1> 
 <dl class=&#34;entry__meta&#34;> 
 <dt>Published</dt> <dd><time …>24 May 2017</time></dd> 
 <dt>Reading Time</dt> <dd>25 minutes</dd> 
 </dl> 
 <div class=&#34;entry__content&#34;> 


I had the great pleasure of delivering a talk… 
 <br><br> I do a lot of traveling and it’s… 
 </div> 


</article>

Slide 45

Slide 45

This is “flow” content with generic divisions

<article class=&#34;entry&#34;> 
 <h1 class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</h1> 
 <dl class=&#34;entry__meta&#34;> 
 <dt>Published</dt> <dd><time …>24 May 2017</time></dd> 
 <dt>Reading Time</dt> <dd>25 minutes</dd> 
 </dl> 
 <div class=&#34;entry__content&#34;> 
 <div>I had the great pleasure of delivering a talk…</div> 
 <div>I do a lot of traveling and it’s…</div> 
 </div> 
 </article>

Slide 46

Slide 46

That is meaningful content

<article class=&#34;entry&#34;> 
 <h1 class=&#34;entry__title&#34;>Progressive Web Apps and 
 the Windows Ecosystem</h1> 
 <dl class=&#34;entry__meta&#34;> 
 <dt>Published</dt> <dd><time …>24 May 2017</time></dd> 
 <dt>Reading Time</dt> <dd>25 minutes</dd> 
 </dl> 
 <div class=&#34;entry__content&#34;> 
 <p>I had the great pleasure of delivering a talk…</p> 
 <p>I do a lot of traveling and it’s…</p> 
 </div> 
 </article>

Slide 47

Slide 47

With CSS it all looks the same anyway, 
 so why should I care?

Slide 48

Slide 48

Readability

Slide 49

Slide 49

Readability

Slide 50

Slide 50

Slide 51

Slide 51

Hey Cortana, read me the top three 
 headlines in today’s New York Times

Slide 52

Slide 52

Accessing content via semantics: function extractHeadlines( response ){ var $html = document.createElement('div'), $headings, i=0, headlines=[]; $html.innerHTML = response.contents; $headings = $html.querySelector('#top-news') 
 .querySelectorAll('article h1, article h2, article h3'); 
 heading_count = $headings.length; 
 while (headlines.length < 3) { let $link = $headings[i].querySelector('a'); 
 if ($link && $link.href) { headlines.push({ 
 title: $headings[i].innerText.trim(), 
 link: $link.href 
 }); } 
 i++; } 
 console.log( headlines ); }

Slide 53

Slide 53

Accessing content via semantics: function extractHeadlines( response ){ var $html = document.createElement('div'), $headings, i=0, headlines=[]; $html.innerHTML = response.contents;

$headings = $html.querySelector('#top-news') 
 .querySelectorAll('article h1, article h2, article h3'); 
 heading_count = $headings.length; 
 while (headlines.length < 3) { let $link = $headings[i].querySelector('a'); 
 if ($link && $link.href) { headlines.push({ 
 title: $headings[i].innerText.trim(), 
 link: $link.href 
 }); } 
 i++; } 
 console.log( headlines ); }

Slide 54

Slide 54

https://aka.ms/dependency-awareness

Slide 55

Slide 55

Let’s say you needed to code a button… <input type="submit" value="Sign Up"> <button type=&#34;submit&#34;>Sign Up</button> 
 <a class=&#34;button&#34; href=&#34;#&#34;>Sign Up</a> 


<div class=&#34;button&#34;>Sign Up</div> Sign Up

Slide 56

Slide 56

Let’s compare Pattern Display Semantics Focusable? Activate By Submits Forms input[type=submit] button button Ye s Mouse, touch, ENTER, SPACE Ye s button[type=submit] button button Ye s Mouse, touch, ENTER, SPACE Ye s a link Named generic Ye s Mouse, touch, ENTER No div block Not exposed No N/A No

Slide 57

Slide 57

UX gaps that need to be filled Pattern Display Semantics Focusable? Activate By Submits Forms input[type=submit] button button Ye s Mouse, touch, ENTER, SPACE Ye s button[type=submit] button button Ye s Mouse, touch, ENTER, SPACE Ye s a link Named generic Ye s Mouse, touch, ENTER No div block Not exposed No N/A No

Slide 58

Slide 58

Filling those gaps introduces dependencies Pattern Display Semantics Focusable? Activate By Submits Forms input[type=submit] None None None None None button[type=submit] None None None None None a CSS ARIA None JavaScript JavaScript div CSS ARIA HTML JavaScript JavaScript

Slide 59

Slide 59

More dependencies, more (potential) problems Dependencies Potential for failure

Slide 60

Slide 60

Disaster averted

Slide 61

Slide 61

More dependencies, more (potential) problems Dependencies Potential for failure

Slide 62

Slide 62

Enhance the experience Capabilities User Experience

Slide 63

Slide 63

Enhancing UX with markup <input type="email" name="email" id="email" 
 required aria-required="true"> Experience deltas 
 1. Support for email input type? 
 2. Va l i d a t i o n a l g o r i t h m i m p l e m e n t e d ? 
 3. Virtual keyboard?

Slide 64

Slide 64

Enhancing UX with markup <input type="email" name="email" id="email" 


required aria-required="true"> Experience deltas 
 1. Support for HTML validation?

Slide 65

Slide 65

Enhancing UX with markup <input type="email" name="email" id="email" 
 required aria-required="true"

Experience deltas 
 1. Browser exposure of aria-required property? 2. Assistive tech implementation of aria-required?

Slide 66

Slide 66

Enhance the experience Capabilities User Experience required validation email validation dedicated keyboard text input required notification

Slide 67

Slide 67

When you think of user experience as a continuum that scales with capabilities, a progressive approach to interfaces is both elegant and powerful.

Slide 68

Slide 68

Step 3 
 Design in support of the core experience

Slide 69

Slide 69

Enhance the experience Capabilities User Experience floats grid blocks positioning flexbox media queries

Slide 70

Slide 70

https://aka.ms/enhanced-css-layouts

Slide 71

Slide 71

I’ve been amazed at how often those outside the discipline of design assume that what designers do is decoration—likely because so much bad design simply is decoration. Good design isn’t. Good design is problem solving. — Jeff Veen

Slide 72

Slide 72

To o l s f o r g r a p h i c d e s i g n · Alignment · Balance · Contrast · Emphasis · Gestalt · Harmony · Movement · Proportion · Proximity · Repetition · Rhythm · Unity · White Space

Slide 73

Slide 73

To o l s f o r g r a p h i c d e s i g n · Alignment · Balance · Contrast · Emphasis · Gestalt · Harmony · Movement · Proportion · Proximity · Repetition · Rhythm · Unity · White Space

Slide 74

Slide 74

Alignment

Slide 75

Slide 75

Contrast

Slide 76

Slide 76

Proportion

Slide 77

Slide 77

Proximity

Slide 78

Slide 78

Rhythm https://aka.ms/vertical-rhythm

Slide 79

Slide 79

Unity

Slide 80

Slide 80

Design considerations unique to the web · Screen size · Resolution · Brightness · Color density · User preference · Network speed & quality · Assistive technology

Slide 81

Slide 81

Design considerations unique to the web · Screen size · Resolution · Brightness · Color density · User preference · Network speed & quality · Assistive technology

Slide 82

Slide 82

Design considerations unique to the web · Screen size · Resolution · Brightness · Color density · User preference · Network speed & quality · Assistive technology  Responsive layouts  SVG, responsive images  Contrast  Color choice, media queries  Responsive images, system fonts

Slide 83

Slide 83

Design considerations unique to the web · Screen size · Resolution · Brightness · Color density · User preference · Network speed & quality · Assistive technology

Slide 84

Slide 84

Examples of user preference · Larger or smaller fonts 
 @media (min-width: 32em) { … } 
 · High contrast colors 
 @media (-ms-high-contrast: active) { … } 
 @media (-ms-high-contrast: white-on-black) { … } 
 @media (-ms-high-contrast: black-on-white) { … } 
 · Reduced motion 
 @media screen and (prefers-reduced-motion: reduce) { … }

Slide 85

Slide 85

Assistive technologies · Vision · Screen magnifiers

· Screen readers

· Braille printers & refreshable braille displays

· High contrast settings

· Motor/mobility · Speech recognition

· Mouse settings

· Keyboards & keyboard overlays

· Eye tracking

· Hearing · Captions & subtitles

Slide 86

Slide 86

Confirm Cancel Confirm Cancel Don’t rely on color alone to convey important information

Slide 87

Slide 87

https://aka.ms/color-contrast Good contrast ensures your content is readable

Slide 88

Slide 88

<a href=&#34;#figure-3-3&#34;>Figure 3.3</a> shows the lodging article in Safari with only the default browser styles applied. 
 …

<figure id=&#34;figure-3-3&#34;> … </figure> Explicit connections ensure everyone can follow references

Slide 89

Slide 89

<a href=&#34;#figure-3-3&#34;>Figure 3.3</a> shows the lodging article in Safari with only the default browser styles applied. 
 …

<figure id=&#34;figure-3-3&#34;> … </figure> Explicit connections ensure everyone can follow references

Slide 90

Slide 90

Provide ample space around 
 interactive elements

Slide 91

Slide 91

<a href=&#34;…&#34;>Finish Reading</a> Consider what 
 your design 
 leaves unsaid

Slide 92

Slide 92

<a href=&#34;…&#34;> 
 <b class=&#34;hidden&#34;>You can</b> 
 finish reading 
 <b class=&#34;hidden&#34;>“The Web 
 Should Just Work for 
 Everyone” in less than 
 10 minutes</b> 
 </a> Consider what 
 your design 
 leaves unsaid

Slide 93

Slide 93

<a href=&#34;…&#34;> 


<b class=&#34;hidden&#34;>You can</b> 
 finish reading 


<b class=&#34;hidden&#34;>“The Web 
 Should Just Work for 
 Everyone” in less than 
 10 minutes</b> 
 </a> Consider what 
 your design 
 leaves unsaid

Slide 94

Slide 94

Enhance the experience Capabilities User Experience

Slide 95

Slide 95

Enhancing design in CSS p { 
 color: green; 
 color: rgba(0, 255, 0, .8); 
 } Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 96

Slide 96

Enhancing design in CSS p { 
 color: green; 


color: rgba(0, 255, 0, .8); 
 } Older browsers without RGBa support, ignore the second rule Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 97

Slide 97

Enhancing design in CSS p { 


color: green; 
 color: rgba(0, 255, 0, .8); 
 } Modern browsers with RGBa support, overwrite the first rule Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 98

Slide 98

Enhancing design in CSS h1:has(+ p) { 
 color: green; 
 } (That selects h1s that have adjacent sibling paragraphs.) Passwords can be 
 a hassle

Slide 99

Slide 99

Enhancing design in CSS h1:has(+ p) { 
 color: green; 
 } Browsers that don’t support :has() ignore the entire rule set Passwords can be 
 a hassle

Slide 100

Slide 100

Enhancing design in CSS h1:has(+ p) { 
 color: green; 
 } As browsers support :has(), matching h1s will turn green Passwords can be 
 a hassle

Slide 101

Slide 101

Enhancing design in CSS @media only screen { 
 p { 
 color: green; 
 } 
 } Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 102

Slide 102

Enhancing design in CSS @media only screen { 
 p { 
 color: green; 
 } 
 } Browsers without media query support ignore the block Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 103

Slide 103

Enhancing design in CSS @media only screen { 
 p { 
 color: green; 
 } 
 } Browsers with media query support apply it Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 104

Slide 104

Enhancing design in CSS @supports (display: grid) { 
 p { 
 color: green; 
 } 
 } Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 105

Slide 105

Enhancing design in CSS @supports (display: grid) { 
 p { 
 color: green; 
 } 
 } Browsers that don’t grok @supports ignore the block Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 106

Slide 106

Enhancing design in CSS @supports (display: grid) { 
 p { 
 color: green; 
 } 
 } Browsers that understand @supports, but don’t display grid ignore it Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 107

Slide 107

Enhancing design in CSS @supports (display: grid) { 
 p { 
 color: green; 
 } 
 } Browsers that understand @supports and grid apply it Passwords can be a hassle. Most people don’t create strong passwords or make sure to maintain a different one for every site. People create easy- to-remember passwords and typically use the same passwords across all of their accounts.

Slide 108

Slide 108

When it comes to HTML & CSS, 
 browsers ignore what they don’t understand

Slide 109

Slide 109

When it comes to HTML & CSS, 
 browsers ignore what they don’t understand 
 
 And new specs smartly override conflicting syntax

Slide 110

Slide 110

https://aka.ms/enhanced-css-layouts

Slide 111

Slide 111

Enhance the experience Capabilities User Experience

Slide 112

Slide 112

“Mobile first” design

Slide 113

Slide 113

.primary { 
 float: left; width: 68%; 
 } .secondary { 
 float: right; width: 32%; 
 } @media (max-width:599px) { 
 .primary, .secondary { float: none; width: auto; 
 } } “Desktop first”

Slide 114

Slide 114

.primary { 
 float: left;

	width:	68%;


 }

.secondary { 
 float: right;

	width:	32%;


 }

@media (max-width:599px) { 
 .primary, .secondary {

			float:	none;	

			width:	auto;


 }

} “Desktop first”

Slide 115

Slide 115

.primary { 
 float: left; width: 68%; 
 } .secondary { 
 float: right; width: 32%; 
 } @media (max-width:599px) { 
 .primary, .secondary { float: none; width: auto; 
 } } “Desktop first”

Slide 116

Slide 116

@media (min-width:600px) { 
 .primary { float: left; width: 68%; 
 } .secondary { 
 float: right; width: 32%; 
 } } “Mobile first”

Slide 117

Slide 117

@media ( min-width:600px ) { 
 .primary { float: left; width: 68%; 
 } .secondary { 
 float: right; width: 32%; 
 } } “Mobile first”

Slide 118

Slide 118

Other ways to design “mobile first” · Selectively deliver advances styles 
 · Isolate large CSS images in min-width media queries 
 · Don’t hide content images using CSS 
 · Use responsive images 
 · Prefer system fonts 
 · font-display: optional

Slide 119

Slide 119

Enhance the experience Capabilities User Experience

Slide 120

Slide 120

Step 4 
 Improve the core experience with JavaScript

Slide 121

Slide 121

When it comes to HTML & CSS, 
 browsers ignore what they don’t understand

Slide 122

Slide 122

When it comes to HTML & CSS, 
 browsers ignore what they don’t understand 
 
 Sadly, that’s not the case with JavaScript

Slide 123

Slide 123

What happens when a browser doesn’t understand let ? document.body.innerHTML += '<p>Can I count to four?</p>’; for ( let i=1; i<=4; i++ ) { document.body.innerHTML += '<p>' + i + '</p>'; } document.body.innerHTML += '<p>Success!</p>';

Slide 124

Slide 124

https://aka.ms/js-let-down

Slide 125

Slide 125

https://aka.ms/js-let-down

Slide 126

Slide 126

More dependencies, more (potential) problems Dependencies Potential for failure

Slide 127

Slide 127

We can and should use JavaScript, 
 but thoughtfully & intentionally

Slide 128

Slide 128

Enhance the experience Capabilities User Experience Server-side render JavaScript Application

Slide 129

Slide 129

Slide 130

Slide 130

Detecting support if ( navigator.credentials ) { 
 // Actual logic goes here }

Slide 131

Slide 131

Creating the credential // Create a credential with WebAuthn APIs navigator.credentials.create({ publicKey: { rp: { /* relying party info / }, user: { / user info / }, authenticatorSelection: { authenticatorAttachment: "platform" }, pubKeyCredParams: [{ type: "public-key", alg: -257 / Accept RS256 credentials */ }], // and other required parameters such as challenge, timeout, ... } }).then(attestation => { // Send the credential to your server, which decodes it and stores the public key sendToServer(attestation); });

Slide 132

Slide 132

Verif ying the credential later // Next time the user visits the page, call the WebAuthn APIs navigator.credentials.get({ publicKey: { allowCredentials: [{ type: "public-key", id: credentialId // ID of credential(s) previously created }] // and other required parameters such as challenge, timeout, ... } }).then(assertion => { // Send the assertion to your server, which decodes it and ensures the // contained signature matches the public key received at credential creation sendToServer(assertion); });

Slide 133

Slide 133

Enhance the experience Capabilities User Experience Normal password WebAuthN

Slide 134

Slide 134

Wait, but don’t Progressive Webs 
 and Service Workers require JavaScript?!

Slide 135

Slide 135

Registering a Service Worker if ( navigator.serviceWorker ) { navigator.serviceWorker.register('/serviceworker.js') .then(function(registration) { console.log('Success!', registration.scope); }) .catch(function(error) { console.error('Failure!', error); }); }

Slide 136

Slide 136

Object detection FTW! if ( navigator.serviceWorker ) { navigator.serviceWorker.register('/serviceworker.js') .then(function(registration) { console.log('Success!', registration.scope); }) .catch(function(error) { console.error('Failure!', error); }); }

Slide 137

Slide 137

Enhance the experience Capabilities User Experience Site PWA

Slide 138

Slide 138

Installed PWA Enhance the experience Capabilities User Experience Site PWA in browser

Slide 139

Slide 139

Enhance the Service Worker Capabilities User Experience Site Offline One-off Sync Less Network 
 Reliance Periodic Sync Push Notifications

Slide 140

Slide 140

Did you know PWAs can 
 enhance via native APIs?

Slide 141

Slide 141

if (window.Windows) { 
 var uiSettings = new Windows.UI 
 .ViewManagement 
 .UISettings(); var color = uiSettings 
 .getColorValue( Windows.UI .ViewManagement 
 .UIColorType .background ); 
 if (color.r == 0 && color.g == 0 
 && color.b == 0) { 
 // changes for Dark Mode 
 } 
 } Detecting “dark mode”

Slide 142

Slide 142

if (window.Windows) { 


var uiSettings = new Windows.UI 
 .ViewManagement 
 .UISettings(); var color = uiSettings 
 .getColorValue( Windows.UI .ViewManagement 
 .UIColorType .background ); 
 if (color.r == 0 && color.g == 0 
 && color.b == 0) { 
 // changes for Dark Mode 
 } 
 } Detecting “dark mode”

Slide 143

Slide 143

if (window.Windows) { 
 var uiSettings = new Windows.UI 
 .ViewManagement 
 .UISettings();

var color = uiSettings 
 .getColorValue( Windows.UI .ViewManagement 
 .UIColorType .background ); 
 if (color.r == 0 && color.g == 0 
 && color.b == 0) { 
 // changes for Dark Mode 
 } 
 } Detecting “dark mode”

Slide 144

Slide 144

if (window.Windows) { 
 var uiSettings = new Windows.UI 
 .ViewManagement 
 .UISettings(); var color = uiSettings 
 .getColorValue( Windows.UI .ViewManagement 
 .UIColorType .background ); 


if (color.r == 0 && color.g == 0 
 && color.b == 0) { 
 // changes for Dark Mode 
 } 
 } Detecting “dark mode”

Slide 145

Slide 145

if (window.Windows) { 
 var uiSettings = new Windows.UI 
 .ViewManagement 
 .UISettings(); var color = uiSettings 
 .getColorValue( Windows.UI .ViewManagement 
 .UIColorType .background ); 
 if (color.r == 0 && color.g == 0 
 && color.b == 0) { 
 // changes for Dark Mode 
 } 
 } Detecting “dark mode”

Slide 146

Slide 146

https://aka.ms/dark-mode-pwa-demo

Slide 147

Slide 147

We can and should use JavaScript, 
 but thoughtfully & intentionally

Slide 148

Slide 148

Enhance the experience Capabilities User Experience

Slide 149

Slide 149

PWAs start with a great web experience and then enhance that experience for performance, resilience, installation, and engagement

Slide 150

Slide 150

PWAs start with a great web experience and then enhance that experience for performance, resilience, installation, and engagement

Slide 151

Slide 151

Focus Markup Design JavaScript

Slide 152

Slide 152

Thank you. 
 
 
 
 
 
 @AaronGustafson 
 @MSEdgeDev 
 PWABuilder.com

Slide 153

Slide 153

© Copyright Microsoft Corporation. All rights reserved.