Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
React in a worker, worker, worker...
Search
stefan judis
May 23, 2019
Technology
600
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
React in a worker, worker, worker...
stefan judis
May 23, 2019
More Decks by stefan judis
See All by stefan judis
Back to boring (part 2)
stefanjudis
0
360
Playwright can do this?
stefanjudis
0
240
Things you should know about Frontend Development in 2022
stefanjudis
0
550
Throw yourself out there for fun and profit
stefanjudis
0
140
Back to Boring
stefanjudis
1
530
Wanna scale up? Make sure your CMS is ready for it!
stefanjudis
0
280
Did we(b development) lose the right direction?
stefanjudis
6
2.2k
Regular expressions – my secret love
stefanjudis
1
1.1k
Write a Function
stefanjudis
0
620
Other Decks in Technology
See All in Technology
「気づいたら仕事が終わっている」バクラクAIエージェント本番運用の裏側 / layerx-bakuraku-aie2026
yuya4
19
11k
チームで実践する AI-DLC 思考の軌跡を残すチェックポイント設計
belongadmin
0
3k
TypeScript Compiler APIとPHP-Parserを活用し、TypeScriptとPHPで型を共有する
shuta13
0
370
【Gen-AX】20260530開催_JJUG CCC 2026 Spring
genax
0
440
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.9k
Mastering Ruby Box
tagomoris
3
150
新規ゲーム開発におけるAI駆動開発のリアル
202409e2
0
2.9k
やさしいA2A入門
minorun365
PRO
4
280
AI活用を推進するために ファインディが下した、一つの小さな決断
starfish719
0
270
Rubyで音を視る
ydah
1
110
2026.06.13_AI時代に事業会社が「SIer出身エンジニア」を求める理由 / Why Businesses Seek Engineers with a System Integrator Background in the AI Era
jumtech
0
880
非エンジニアがClaudeと挑んだ「1ヶ月間プロダクト30本ノック」
askokc
0
100
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
180
The Pragmatic Product Professional
lauravandoore
37
7.3k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
320
Writing Fast Ruby
sferik
630
63k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
600
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
140
Abbi's Birthday
coloredviolet
2
8k
Tell your own story through comics
letsgokoyo
1
950
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
430
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
550
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
Transcript
@stefanjudis React in a worker, worker, worker, worker...
@stefanjudis www.stefanjudis.com Heyo, I'm Stefan!
Let's talk about CRA (create-react-app)
None
A classical Single Page App
There are problems with typical single page apps...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut
icon" href="/favicon.ico" /> <meta name="viewport" content="[ ...]" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> <title>React App </title> </head> <body> <noscript>No JavaScriptzzzz ... </noscript> <div id="root"> </div> <script src="/static/js/bundle.js"> </script> <script src="/static/js/0.chunk.js"> </script> <script src="/static/js/main.chunk.js"> </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut
icon" href="/favicon.ico" /> <meta name="viewport" content="[ ...]" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> <title>React App </title> </head> <body> <noscript>No JavaScriptzzzz ... </noscript> <div id="root"> </div> <script src="/static/js/bundle.js"> </script> <script src="/static/js/0.chunk.js"> </script> <script src="/static/js/main.chunk.js"> </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut
icon" href="/favicon.ico" /> <meta name="viewport" content="[ ...]" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> <title>React App </title> </head> <body> <noscript>No JavaScriptzzzz ... </noscript> <div id="root"> </div> <script src="/static/js/bundle.js"> </script> <script src="/static/js/0.chunk.js"> </script> <script src="/static/js/main.chunk.js"> </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut
icon" href="/favicon.ico" /> <meta name="viewport" content="[ ...]" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> <title>React App </title> </head> <body> <noscript>No JavaScriptzzzz ... </noscript> <div id="root"> </div> <script src="/static/js/bundle.js"> </script> <script src="/static/js/0.chunk.js"> </script> <script src="/static/js/main.chunk.js"> </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut
icon" href="/favicon.ico" /> <meta name="viewport" content="[ ...]" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> <title>React App </title> </head> <body> <noscript>No JavaScriptzzzz ... </noscript> <div id="root"> </div> <script src="/static/js/bundle.js"> </script> <script src="/static/js/0.chunk.js"> </script> <script src="/static/js/main.chunk.js"> </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut
icon" href="/favicon.ico" /> <meta name="viewport" content="[ ...]" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> <title>React App </title> </head> <body> <noscript>No JavaScriptzzzz ... </noscript> <div id="root"> </div> <script src="/static/js/bundle.js"> </script> <script src="/static/js/0.chunk.js"> </script> <script src="/static/js/main.chunk.js"> </script> </body> </html> No JavaScript zzzz ...
13 Million requests for JavaScript will time out. Ian Feather
(Buzzfeed)
"We don't have any non- JavaScript users". No, all your
users are non-JS while they're downloading your JS. Jake Archibald (Google)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut
icon" href="/favicon.ico" /> <meta name="viewport" content="[ ...]" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> <title>React App </title> </head> <body> <noscript>No JavaScriptzzzz ... </noscript> <div id="root"> </div> <script src="/static/js/bundle.js"> </script> <script src="/static/js/0.chunk.js"> </script> <script src="/static/js/main.chunk.js"> </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut
icon" href="/favicon.ico" /> <meta name="viewport" content="[ ...]" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> <title>React App </title> </head> <body> <noscript>No JavaScriptzzzz ... </noscript> <div id="root"> </div> <script src="/static/js/bundle.js"> </script> <script src="/static/js/0.chunk.js"> </script> <script src="/static/js/main.chunk.js"> </script> </body> </html> The spinner of death
How can we do better?
proxx.app
nextjs.org www.gatsbyjs.org
nextjs.org www.gatsbyjs.org Run the same React code on the server
and client
None
None
None
None
bundle.js
bundle.js
bundle.js Interactive
Better performance!
Better performance! Faster indexed by Google!
Better performance! Faster indexed by Google! It's the same code
front to back!
But is it really the same code?
module.exports = global.fetch = global.fetch || (typeof process == 'undefined'
? require('unfetch').default || require('unfetch') : function(url, opts) { return require('node-fetch')(url.replace(/^\/\ //g, 'https: //'), opts); });
github.com/developit/unfetch/tree/master/packages/isomorphic-unfetch
What if we serve HTML from an environment with the
same methods?
The Service Worker worker.js
if ('serviceWorker' in navigator) { navigator.serviceWorker .register('/worker.js') .then(function(registration) {}, function(err)
{}); }
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); } ) ); });
Let's try an experiment?
Crowd Coding...
What did just happen?
None
localhost:8080
localhost:8080
localhost:8080 worker.js
localhost:8080 worker.js
localhost:8080 worker.js Interactive
localhost:8080 worker.js Interactive
localhost:8080 worker.js Interactive
localhost:8080 worker.js Interactive
localhost:8080 worker.js Interactive
localhost:8080 worker.js Interactive
worker.js
worker.js
worker.js
worker.js
Could universal workers be a thing?
Let's create a cloud worker!
www.cloudflare.com/products/cloudflare-workers/
developers.cloudflare.com/workers/reference/
developers.cloudflare.com/workers/reference/
developers.cloudflare.com/workers/reference/
https://dash.cloudflare.com/9dcd7c...
worker.js
worker.js
worker.js
worker.js
worker.js
worker.js
worker.js
worker.js
worker.js worker.js
worker.js worker.js
worker.js worker.js
worker.js
worker.js
worker.js
worker.js
worker.js
Is this the solution to universal JavaScript?
Service worker development is still very tedious
Cache handling is tough
It's worth investigating!
Servers with browser APIs will change how we share code!
react-in-a-worker.netlify.com
www.react-in-a-worker.rocks
github.com/stefanjudis/react-in-a-worker
One last thing...
... let's serve HTML instead of spinners.
@stefanjudis
[email protected]
www.stefanjudis.com Thanks.