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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
sota ohara
July 21, 2020
Technology
320
1
Share
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
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.7k
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
非同期・イベント駆動処理の分散トレーシングの繋げ方
ichikawaken
1
250
パワポ作るマンをMCP Apps化してみた
iwamot
PRO
0
260
GitHub Copilot CLI で Azure Portal to Bicep
tsubakimoto_s
0
300
Navigation APIと見るSvelteKitのWeb標準志向
yamanoku
2
140
契約書からの情報抽出を行うLLMのスループットを、バッチ処理を用いて最大40%改善した話
sansantech
PRO
3
330
ハーネスエンジニアリング×AI適応開発
aictokamiya
2
990
Network Firewall Proxyで 自前プロキシを消し去ることができるのか
gusandayo
0
150
Why we keep our community?
kawaguti
PRO
0
360
【AWS】CloudTrail LakeとCloudWatch Logs Insightsの使い分け方針
tsurunosd
0
130
AIエージェント勉強会第3回 エージェンティックAIの時代がやってきた
ymiya55
0
180
第26回FA設備技術勉強会 - Claude/Claude_codeでデータ分析 -
happysamurai294
0
270
トイルを超えたCREは何屋になるのか
bengo4com
0
110
Featured
See All Featured
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
450
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
10k
Balancing Empowerment & Direction
lara
5
1k
Navigating Team Friction
lara
192
16k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
470
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
230
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Language of Interfaces
destraynor
162
26k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
290
GitHub's CSS Performance
jonrohan
1032
470k
Typedesign – Prime Four
hannesfritz
42
3k
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