Slide 1

Slide 1 text

@stefanjudis Did we(b development) lose the right direction?

Slide 2

Slide 2 text

This is a talk about general "best practices"...

Slide 3

Slide 3 text

This is a rant about general "best practices"...

Slide 4

Slide 4 text

@stefanjudis news.stefanjudis.com Heyo, I'm Stefan!

Slide 5

Slide 5 text

The state of web development ten years ago...

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

yslow.org

Slide 9

Slide 9 text

4waisenkinder.de

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

I love technology and I love writing JavaScript!

Slide 13

Slide 13 text

stefanjudis.com 2017 - 2020

Slide 14

Slide 14 text

Chrome – Cable iPhone 6 – 3G

Slide 15

Slide 15 text

Usually, any score above a 90 gets you in the top ~5% of performant websites. Lighthouse documentation

Slide 16

Slide 16 text

HTTP/2 Everything's compressed and minified!

Slide 17

Slide 17 text

github.com/webpack-contrib/webpack-bundle-analyzer Code splitting

Slide 18

Slide 18 text

www.fmboschetto.it

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

webpagetest.org/video/

Slide 22

Slide 22 text

webpagetest.org/video/view.php?id=200302_2df0157ba9ea8586f5d987f7a1c3d52ed5e2a874 Chrome – Cable

Slide 23

Slide 23 text

Stefan, you just messed it up!

Slide 24

Slide 24 text

Maybe, but how can it be so easy to mess up?

Slide 25

Slide 25 text

stefanjudis.com fmboschetto.it 4waisenkinder.de Overall page weight 340KB / 940KB 265KB / 284KB 159KB / 300KB index.html 108KB / 340KB 8KB / 32KB 6KB / 18KB CSS resources 1 0 1 Images resources 0* 32 (246KB / 254KB) 0* Speed Index (LTE) 1.4s / 0.8s 2.1s / 0.7s 2.3s / 1.5s JS resources 22 (183KB / 512KB) 6 (68KB / 177KB) 2 (2KB / 6KB) *ignoring tracking pixel Lighthouse Perf Score 100 97 90

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

10% - First contentful paint 10% - Time to interactive 10% - Speed Index 25% - Largest contentful paint 30% - Total blocking time 15% - Cumulative layout shift JavaScript blocks the main-thread!

Slide 28

Slide 28 text

paulirish.github.io/lh-scorecalc/ calibreapp.com/blog/lighthouse-changes-scoring-algorithm

Slide 29

Slide 29 text

www.youtube.com/watch?v=Lx1cYJAVnzA

Slide 30

Slide 30 text

timkadlec.com/remembers/2020-04-21-the-cost-of-javascript-frameworks/ Scripting related CPU time (in milliseconds) for mobile devices in percentiles Median

Slide 31

Slide 31 text

medium.com/dev-channel/a-netflix-web-performance-case-study-c0bcde26a9d9

Slide 32

Slide 32 text

A 150KB image is not comparable to 150KB of gzipped JavaScript!

Slide 33

Slide 33 text

Page weight is not equal page weight!

Slide 34

Slide 34 text

That's a 340KB index file for roughly 400 words, Stefan?

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

"It's great because it's fast! And it's still lighter than the rest of the internet..."

Slide 37

Slide 37 text

"It's great because it's still lighter than the rest of the internet..." "I'm really digging the tech-stack!"

Slide 38

Slide 38 text

That's a 340KB index file for roughly 400 words, Stefan? window.__DATA__=function( e,t,n,o,i,/* ... */ ){ return /* ... */ )

Slide 39

Slide 39 text

I decided to preload/inline 22 articles ... (at an average session length of 1.17 pages)

Slide 40

Slide 40 text

... for "better performance".

Slide 41

Slide 41 text

Making a very fast website is extremely hard!

Slide 42

Slide 42 text

Making a very fast website is extremely hard! (But is it really?)

Slide 43

Slide 43 text

twitter.com/philhawksworth/status/1038440732741259265

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

www.11ty.dev/docs/performance-leaderboard/

Slide 46

Slide 46 text

www.youtube.com/watch?v=88K8oO_dYbI

Slide 47

Slide 47 text

www.youtube.com/watch?v=88K8oO_dYbI Today, I 100% disagree with "past me", ...

Slide 48

Slide 48 text

www.youtube.com/watch?v=88K8oO_dYbI ... because where is the user's benefit from such overhead?

Slide 49

Slide 49 text

A common "best practice" Universal JavaScript apps for content-sites

Slide 50

Slide 50 text

Hello world!

Slide 51

Slide 51 text

Hello world!

window.__data__ = { greeting: "Hello world!" }

Slide 52

Slide 52 text

Hello world!

window.__data__ = { greeting: "Hello world!" } The same code runs on the server and on the client!

Slide 53

Slide 53 text

Your content in HTML The same content in JavaScript

Slide 54

Slide 54 text

Is this really the best way for the user?

Slide 55

Slide 55 text

"This architecture o!ers doors to progressive enhancement!"

Slide 56

Slide 56 text

Base functionality Enhanced experience If the enhancement fails, it still works!

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Updated search results Updated URL Submittable form

Slide 60

Slide 60 text

Buzzfeed twitter.com/philhawksworth/status/990890920672456707

Slide 61

Slide 61 text

"We don't have any non-JavaScript users" No, all your users are non-JS while they're downloading your JS. Jake Archibald

Slide 62

Slide 62 text

github.com POST github.com/stefanjudis/test/issue_comments handles a form and AJAX submit Five "old school" HTML links

Slide 63

Slide 63 text

I’m happy with GitHub's experience. A good site "just works".™

Slide 64

Slide 64 text

What's the enhancement in the wild, though?

Slide 65

Slide 65 text

reactjs.org with JavaScript reactjs.org without JavaScript 433KB / 1.1MB 49KB / 175KB Initial weight 547KB / 2.3MB 100KB / 1.0MB Weight after 4 navigations

Slide 66

Slide 66 text

I'm guilty of that, too!

Slide 67

Slide 67 text

Does this architecture improve user experience?

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

You get 6MB for 2Euros but you have only 24h to use them! Right...

Slide 70

Slide 70 text

httparchive.org/reports/state-of-the-web

Slide 71

Slide 71 text

whatdoesmysitecost.com

Slide 72

Slide 72 text

httparchive.org/reports/state-of-the-web We ship more data for the same experience...

Slide 73

Slide 73 text

Maybe app frameworks are for apps after all?

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

5.2MB / 17MB 25KB / 40KB

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

The web is not as cutting-edge as it seems...

Slide 78

Slide 78 text

... boring is beautiful! (and fast)

Slide 79

Slide 79 text

"Benefits" of client-side routing

Slide 80

Slide 80 text

Developers are "allowed" to re-implement an accessible navigation

Slide 81

Slide 81 text

twitter.com

Slide 82

Slide 82 text

www.gatsbyjs.org/blog/2020-02-10-accessible-client-side-routing-improvements/

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

github.com/sdras/page-transitions-travelapp

Slide 85

Slide 85 text

async function navigateToSettingsPage() { await document.documentTransition.prepare({ rootTransition: 'cover-left', }); updateDOMForSettingsPage(); await document.documentTransition.start(); } developer.chrome.com/blog/shared-element-transitions-for-spas/ chrome://flags/#document-transition

Slide 86

Slide 86 text

There’s a chance I believe client side routing on the web is usually not preferred. Which is ironic. Ryan Florence (co-author React-Router) twitter.com/ryanflorence/status/1186515553285857280

Slide 87

Slide 87 text

vuejs.org/v2/guide/installation.html

Slide 88

Slide 88 text

vuejs.org/v2/guide/installation.html

Slide 89

Slide 89 text

We use too much JavaScript!

Slide 90

Slide 90 text

kit.svelte.dev astro.build

Slide 91

Slide 91 text

The modern web seems to focus an awful lot on JavaScript. We don’t think it has to [...]. astro.build

Slide 92

Slide 92 text

Your content in HTML Multi-page App (MPA) The same content in JavaScript Single-page App (SPA)

Slide 93

Slide 93 text

Your content in HTML Multi-page App (MPA) The same content in JavaScript Single-page App (SPA)

Slide 94

Slide 94 text

jasonformat.com/islands-architecture/

Slide 95

Slide 95 text

/# Opt in to load client-side JavaScript *%

Slide 96

Slide 96 text

works with

Slide 97

Slide 97 text

vercel.com reacts.org

Slide 98

Slide 98 text

Have Single-Page Apps Ruined the Web? #transitionalApps

Slide 99

Slide 99 text

A great site just works.™

Slide 100

Slide 100 text

HTML CSS JavaScript The foundation of the web

Slide 101

Slide 101 text

A great site doesn't have to be built with React/Vue/Angular/...

Slide 102

Slide 102 text

I need a new site what should I use? You should use Framework X with SSR, an offline strategy and it has to run "on the edge"! It depends... What's your use case?

Slide 103

Slide 103 text

A great site can be built with React, Vue, Angular...

Slide 104

Slide 104 text

A great site is accessible, fast, secure, ...

Slide 105

Slide 105 text

It's "just" HTML...

Slide 106

Slide 106 text

HTML defines over 100 elements

Slide 107

Slide 107 text

HTML defines 22 input types

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

css-tricks.com/a-complete-guide-to-links-and-buttons/ +4000 words!

Slide 110

Slide 110 text

Twitter <(div>

Slide 111

Slide 111 text

www.htmhell.dev

Slide 112

Slide 112 text

... it's not "easy".

Slide 113

Slide 113 text

webaim.org/projects/million/

Slide 114

Slide 114 text

webaim.org/projects/million/

Slide 115

Slide 115 text

webaim.org/projects/million/

Slide 116

Slide 116 text

thenextweb.com/contributors/2018/03/10/protect-website-cryptojacking-attacks/

Slide 117

Slide 117 text

Content-Security-Policy: default-src 'self'; script-src 'self' just- comments.com www.google-analytics.com production- assets.codepen.io storage.googleapis.com; style-src 'self' 'unsafe- inline'; img-src 'self' data: images.contentful.com images.ctfassets.net www.gravatar.com www.google-analytics.com just-comments.com; font-src 'self' data:; connect-src 'self' cdn.contentful.com images.contentful.com videos.contentful.com images.ctfassets.net videos.ctfassets.net service.just-comments.com www.google- analytics.com; media-src 'self' videos.contentful.com videos.ctfassets.net; object-src 'self'; frame-src codepen.io; frame- ancestors 'self'; worker-src 'self'; block-all-mixed-content; manifest-src 'self' 'self'; disown-opener; prefetch-src 'self'; report-uri https:// stefanjudis.report-uri.com/r/d/csp/reportOnly

Slide 118

Slide 118 text

USE CSP DON'T USE CSP 89% 11%

Slide 119

Slide 119 text

httparchive.org/reports/state-of-the-web

Slide 120

Slide 120 text

The web lost quality...

Slide 121

Slide 121 text

... but at least Frontend developers got more productive!

Slide 122

Slide 122 text

No content

Slide 123

Slide 123 text

No content

Slide 124

Slide 124 text

exports.sayHello = async (event) =" { return 'Hello from Lambda!'; };

Slide 125

Slide 125 text

exports.sayHello = async (event) =" { return { statusCode: 200, body: JSON.stringify({"msg": "Hello from Lambda!"}) }; };

Slide 126

Slide 126 text

The options are limitless to build a product quickly!

Slide 127

Slide 127 text

Hello world! 2010 10KB / 50KB Hello world! 2020 40KB / 130KB Complexity

Slide 128

Slide 128 text

I just added two helpers to tiny-helpers.dev. The site is great, but that I had to download 700MB of Node.js stuff is brutal. :)

Slide 129

Slide 129 text

A text editor A text editor, Node.js, npm, framework knowledge, …

Slide 130

Slide 130 text

I’ve been building on the web for 15+ years in some capacity, and it has never been so easy to build complex apps. Josh Comeau 100% agree! How many sites need to be complex apps, though?

Slide 131

Slide 131 text

Where are we going with this trend?

Slide 132

Slide 132 text

No content

Slide 133

Slide 133 text

HTML CSS JavaScript React Vue Angular Svelte webpack Rollup Parcel AWS GCloud Netlify Vercel Heroku * * a very incomplete list

Slide 134

Slide 134 text

Complexity rocks! (but what for?)

Slide 135

Slide 135 text

No content

Slide 136

Slide 136 text

twitter.com/_developit/status/1214258470226190350

Slide 137

Slide 137 text

(function() { const fakeButton = document.querySelector('[data-menu-button]'); const menu = document.querySelector('[data-menu]'); const toggleMenuButton = document.createElement('button'); toggleMenuButton.textContent = fakeButton.textContent; toggleMenuButton.setAttribute('aria-expanded', false); toggleMenuButton.setAttribute('aria-controls', 'menu'); toggleMenuButton.classList.add('nav__toggle'); fakeButton.parentNode.replaceChild(toggleMenuButton, fakeButton); toggleMenuButton.addEventListener('click', function() { let expanded = this.getAttribute('aria-expanded') === 'true' || false; this.setAttribute('aria-expanded', !expanded); menu.hidden = !menu.hidden; }); menu.hidden = true; })() justmarkup.com/articles/2019-12-04-hamburger-menu/ 16 lines of hand-written JavaScript

Slide 138

Slide 138 text

Maybe we'll have good enough abstractions one day, but today…

Slide 139

Slide 139 text

… you still have to know web fundamentals to create the best user experience.

Slide 140

Slide 140 text

You're shaping tomorrow's job market based on the technology choices you make today. Henrik Joreteg

Slide 141

Slide 141 text

Your job as a web developer is to build beautiful experiences!

Slide 142

Slide 142 text

Your job as a web developer is to build beautiful experiences! Your job as a developer is to decide, to decide what tools to use, to decide what frameworks to use, to decide what to prioritize, to decide what is the best way to maintain a project. Michael Scharnagl

Slide 143

Slide 143 text

Chatted with someone who’s been working at a company as a front-end developer for 3 years. Their friend asked them to help build a website, but they had to decline. They didn’t know how. Chris Coyier (css-tricks.com)

Slide 144

Slide 144 text

HTML CSS JavaScript React Vue Angular Svelte webpack Rollup Parcel AWS GCloud Netlify Vercel Heroku * * a very incomplete list

Slide 145

Slide 145 text

css-tricks.com/the-great-divide/

Slide 146

Slide 146 text

css-tricks.com/the-great-divide/

Slide 147

Slide 147 text

css-tricks.com/the-great-divide/

Slide 148

Slide 148 text

It's time for our industry to realize the title "frontend developer" is obsolete. Benjamin De Cock – @bdc

Slide 149

Slide 149 text

Developers and software engineers put their job satisfaction above their users or customers.

Slide 150

Slide 150 text

Your users don't care about your technical implementation.

Slide 151

Slide 151 text

DX (developer experience) UX (user experience)

Slide 152

Slide 152 text

DX (developer experience) UX (user experience)

Slide 153

Slide 153 text

I love shiny tools and I love writing JavaScript...

Slide 154

Slide 154 text

... but maybe we should take a step back? And consider the right tools for the best user experience?

Slide 155

Slide 155 text

2020+ 2017 - 2020

Slide 156

Slide 156 text

2020+ Reduction of overall page weight by 64%.

Slide 157

Slide 157 text

2020+ Reduction of build time from 4min to 40s.

Slide 158

Slide 158 text

2020+ No JavaScript build pipeline leading to reduced complexity.

Slide 159

Slide 159 text

2020+ No JavaScript build pipeline leading to reduced complexity.

Slide 160

Slide 160 text

2020+ A green lighthouse score.

Slide 161

Slide 161 text

2020+ A site with a better user experience.

Slide 162

Slide 162 text

Is a JavaScript-driven stack really that bad?

Slide 163

Slide 163 text

Not at all, use whatever makes you happy!

Slide 164

Slide 164 text

Every technology decision has tradeo!s. Kevlin Henney

Slide 165

Slide 165 text

But maybe we should focus more on building sites that just work... (And worry less about the technology powering them)

Slide 166

Slide 166 text

Slides my-links.online/did-we-lose-direction Yes! I own that domain! !

Slide 167

Slide 167 text

@stefanjudis www.stefanjudis.com newsletter.stefanjudis.com Thanks.