Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
350
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Implement prerendering w/ puppeteer
sota ohara
July 21, 2020
Transcript
14 slides
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
More Decks by sota ohara
See All by sota ohara
Re-Architecture of ReactNative
sottar
0
320
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
Amazon EFS のマルウェアスキャンをClamAV で自前実装したら苦労した話
mtmtfactory01
0
120
新規事業開発でのAWS活用成功談&失敗談! 〜新規事業開発を専門に行うRelicならではのAWS活用〜
amixedcolor
1
150
クラウドでも使えるNetApp -現場目線での設計とクラウドバックアップの活用
ryutakondo
1
330
リリースしたで終わらない。 観測できるフロントエンド開発
yamakenji24
4
590
AI-DLCでソフトウェア開発の速さは 上がったのか?
rfdnxbro
0
170
メディアアートを〈拡張〉する——器官学と個体化論を手がかりに
_kotobuki_
0
290
落とし穴にハマってわかった 開発生産性を測るときに気をつけたいこと
munakata
3
500
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
20
29k
Metadata - Section 4 : MODS (Metadata Object Description Schema )
mohab1
0
130
RAGの改善を速く回すための評価基盤
yosukeyoshida
6
3.6k
Taking back control of your AI development
inesmontani
PRO
0
310
ポケモンバトルのAIエージェント
koji_kawamura
0
250
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
4
660
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.2k
Designing for humans not robots
tammielis
254
26k
Designing for Timeless Needs
cassininazir
1
570
Building the Perfect Custom Keyboard
takai
2
970
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.3k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
1k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
530
From π to Pie charts
rasagy
1
460
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
540
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k