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
Implement prerendering w/ puppeteer
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
sota ohara
July 21, 2020
Technology
1
320
Implement prerendering w/ puppeteer
sota ohara
July 21, 2020
Tweet
Share
More Decks by sota ohara
See All by sota ohara
Re-Architecture of ReactNative
sottar
0
290
create own CMS from scratch
sottar
2
9.1k
Let’s try to hack AST of JavaScript
sottar
1
1.8k
フロントエンドエンジニアが伝えたい最近の事情
sottar
27
18k
複数人で高速に開発するためのnpmモジュール
sottar
5
2.6k
new version of context in React 16.3
sottar
3
1.8k
2ヶ月半でサービスをリリースした話し
sottar
2
2.3k
Redux のディレクトリ構成を考える
sottar
2
15k
モダンなJavaScriptアプリケーションでモダンにスタイリングする方法
sottar
9
5k
Other Decks in Technology
See All in Technology
[JAWSDAYS2026]Who is responsible for IAM
mizukibbb
0
770
CyberAgentの生成AI戦略 〜変わるものと変わらないもの〜
katayan
0
250
複数クラスタ運用と検索の高度化:ビズリーチにおけるElastic活用事例 / ElasticON Tokyo2026
visional_engineering_and_design
0
160
visionOS 開発向けの MCP / Skills をつくり続けることで XR の探究と学習を最大化
karad
1
260
楽しく学ぼう!ネットワーク入門
shotashiratori
4
3.4k
AWS CDK「読めるけど書けない」を脱却するファーストステップ
smt7174
3
160
非情報系研究者へ送る Transformer入門
rishiyama
12
7.6k
AWSの資格って役に立つの?
tk3fftk
2
350
S3はフラットである –AWS公式SDKにも存在した、 署名付きURLにおけるパストラバーサル脆弱性– / JAWS DAYS 2026
flatt_security
0
1.8k
詳解 強化学習 / In-depth Guide to Reinforcement Learning
prinlab
0
220
猫でもわかるKiro CLI(AI 駆動開発への道編)
kentapapa
0
240
モブプログラミング再入門 ー 基本から見直す、AI時代のチーム開発の選択肢 ー / A Re-introduction of Mob Programming
takaking22
5
1.6k
Featured
See All Featured
KATA
mclloyd
PRO
35
15k
Six Lessons from altMBA
skipperchong
29
4.2k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
How GitHub (no longer) Works
holman
316
140k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Docker and Python
trallard
47
3.8k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
280
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
83
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
Side Projects
sachag
455
43k
Odyssey Design
rkendrick25
PRO
2
550
Transcript
Implement prerendering w/ puppeteer 2020.07.21 隅田川.js#2 Sota Ohara
Sota Ohara Software Engineer at CADDi sottar_ sottar
https://www.sottar.io/
prerendering とは - Web 上でレンダリングをする方法の一つ - CSR, SSR などと並列 -
各URLに対応する個別の HTML ファイルを事前に生成しておく - TTFB, FP, FCP, TTI の最適化 - エッジキャッシュを活用しやすい - 全ての有効なURLに対してHTMLを生成しておく必要がある - Gatsby, Next.js などでサポートされている
https://developers.google.com/web/updates/2019/02/rendering-on-the-web
puppeteer を使って実装した
puppeteer とは - https://github.com/puppeteer/puppeteer - Headless Chrome Node.js API -
ヘッドレス(GUIなし)で Chrome を制御できるライブラリ - react-snap や Gatsby の内部で使われている
登場人物 react, styled-components, puppeteer, webpack, express, MySQL, npm scripts
Application npm run build ① npm run prerender ② bundle.js
index.html npm-scripts
OGP対応 - OGP タグは react-helmet を使う - OGP用の画像は puppeteer でスクリーンショットを撮ることができる
styled-components のスタイルが取得できない - puppeteer を使ってページの HTML を取得する際に styled-components で当てて いるスタイルの情報が取得できなかった
- パフォーマンス観点から CSSOM を直接読み込ませているので puppeteer で取得できない - styled-components v5 から導入された disableCSSOMInjection オプションを指定 することで回避
page source Before After
None
We Are Hiring!! https://corp.caddi.jp/recruit/eng