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.2k
Redux のディレクトリ構成を考える
sottar
2
15k
モダンなJavaScriptアプリケーションでモダンにスタイリングする方法
sottar
9
5k
Other Decks in Technology
See All in Technology
AI が Approve する開発フロー / How AI Reviewers Accelerate Our Development
zaimy
1
260
Eight Engineering Unit 紹介資料
sansan33
PRO
1
6.9k
入門DBSC
ynojima
0
130
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
360
Digitization部 紹介資料
sansan33
PRO
1
7k
Webアクセシビリティ技術と実装の実際
tomokusaba
0
210
生成AIの利用とセキュリティ /gen-ai-and-security
mizutani
0
1k
Ultra Ethernet (UEC) v1.0 仕様概説
markunet
3
170
Oracle Cloud Infrastructure:2026年2月度サービス・アップデート
oracle4engineer
PRO
0
210
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
44k
実録・Platform Engineering 失敗から学び、AI時代の波を乗りこなす技術
sansantech
PRO
1
100
OCI Security サービス 概要
oracle4engineer
PRO
2
13k
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.8k
Darren the Foodie - Storyboard
khoart
PRO
3
2.7k
Exploring anti-patterns in Rails
aemeredith
2
280
Raft: Consensus for Rubyists
vanstee
141
7.3k
Color Theory Basics | Prateek | Gurzu
gurzu
0
220
Embracing the Ebb and Flow
colly
88
5k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
270
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
97
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
240
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
RailsConf 2023
tenderlove
30
1.4k
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