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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
機械学習を「社会実装」するということ 2026年夏版 / Social Implementation of Machine Learning June 2026 Version
moepy_stats
6
2.4k
Claude Codeとのおしゃべりでセマンティックモデルの定義からダッシュボード作成まで完成させる
nic_sugiyama
0
120
やさしいA2A入門
minorun365
PRO
12
1.9k
【セミナー資料】Claude Code をセキュアに使うための考え方と設定の勘どころ / Claude Code Webinar 20260616
masahirokawahara
2
360
小さく始める AI 活用推進 ― 日経電子版 Web チームの事例/nikkei-tech-talk47
nikkei_engineer_recruiting
0
270
MCP Appsを作ってみよう
iwamot
PRO
4
660
GitHub Copilot 最新アップデート – 「一歩先」の実践活用術
moulongzhang
4
1.1k
攻撃者視点で考えるDetection Engineering
cryptopeg
3
1.9k
自宅LLMの話
jacopen
1
600
フィジカル版Github Onshapeの紹介
shiba_8ro
0
260
【Snowflake Summit 2026 Recap!!】Snowflake Summit Deep Dive: Security & Governance
civitaspo
1
220
AIはどのように 組織のアジリティを変えるのか?
junki
4
940
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
Ruling the World: When Life Gets Gamed
codingconduct
0
250
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
The SEO identity crisis: Don't let AI make you average
varn
0
490
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
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.