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
sota ohara
July 21, 2020
Technology
340
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Implement prerendering w/ puppeteer
sota ohara
July 21, 2020
More Decks by sota ohara
See All by sota ohara
Re-Architecture of ReactNative
sottar
0
300
create own CMS from scratch
sottar
2
9.2k
Let’s try to hack AST of JavaScript
sottar
1
1.9k
フロントエンドエンジニアが伝えたい最近の事情
sottar
27
18k
複数人で高速に開発するためのnpmモジュール
sottar
5
2.7k
new version of context in React 16.3
sottar
3
1.9k
2ヶ月半でサービスをリリースした話し
sottar
2
2.3k
Redux のディレクトリ構成を考える
sottar
2
15k
モダンなJavaScriptアプリケーションでモダンにスタイリングする方法
sottar
9
5.1k
Other Decks in Technology
See All in Technology
【CEDEC2026】ゲームシナリオライターを支援するAIツール開発の実践 ― 設計とプロンプトの工夫 ―
cygames
PRO
1
800
攻撃と防御で学ぶAI時代のプロダクトセキュリティ演習
recruitengineers
PRO
9
2.7k
【CEDEC2026】次世代デジタルカードゲームのサーバー設計と運用 〜『Shadowverse: Worlds Beyond』の舞台裏~
cygames
PRO
1
1.2k
システム思考で問題に対処する
yussak
0
260
つくって納得、つかって実感! 大規模言語モデルことはじめ ver2.0
recruitengineers
PRO
4
1.6k
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
180
ボトムアップ文化が強い組織で セキュリティをどう根付かせていくかの現在進行形の話 / Making Security Stick in a Bottom-Up Organization
yamaguchitk333
0
220
[ChatGPT Work LT]事務作業が苦手な人のための バックオフィスの「半」自動化
chimaki_iot
0
280
強化学習「理論」入門
enakai00
3
3.6k
ハーレムエンジニアリング
kazuma777777
0
140
関東Kaggler会発表資料
takoi
1
220
ブラウザ研修 2026
recruitengineers
PRO
6
980
Featured
See All Featured
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
660
Between Models and Reality
mayunak
4
390
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
200
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
220
Google's AI Overviews - The New Search
badams
0
1.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
650
How to build a perfect <img>
jonoalderson
1
5.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
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