[Feat] Implement Static fallback via the Maps Static API
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- frontend, performance, web-dev
調査の方向性
src/components/map/index.tsx と APIProvider コンテキストから始め、リンクされた static-facade コミットのプロトタイプと比較します。ドキュメント化された center および zoom props を使用して StaticMap パスを実装し、ユーザーが操作するまで通常のマップの読み込みを遅延させ、操作が必要であることを示す UI を提供します。
索引モデルが issue の本文から書いたものです。
説明
Target Use Case
Minimize the user experience impact of the library by improving paint time and responsiveness metrics.
Proposal
Data from HTTP Archive shows that Google Maps has the longest download times during page rendering when compared to the other most popular third-party libraries on the web:
| Median download time during page rendering for the top 10 most popular third parties (calculated using HTTP Archive and Lighthouse’s wastedMs attribute via the render blocking audit) |
| Query |
This happens because the Maps JavaScript API fetches ~240 kB of JavaScript across multiple scripts. In this library, we can circumvent this by delaying the instantiation of these scripts until the user engages with the map. While waiting for the user’s interaction, we can fetch and display an image via the Maps Static API passing in the same set of required props (center and zoom).
Optimized prototype of react-google-maps that displays an image and defers JS until user interaction) |
| Link |
To implement this feature, the <APIProvider> component of the library can keep track of whether the map has been selected as part of the context information it provides. We can use this to conditionally render either the “real” map versus a static version of it:
// src/components/map/index.tsx
import { StaticMap } from "./static-map";
// ...
return (
<div onClick={() => context.setMapSelected(true)}>
>
{context.mapSelected ? (
// Load normal map
) : (
<StaticMap {...props} /> // Load Static Map if map hasn't been clicked
)}
</div>
);
You can see all the changes in this prototype in this commit. Note that this is just a prototype, and the real implementation would offer some sort of UI that makes it clear that the map needs to be clicked in order to be interacted with.
Performance Tests
Comparing the current version of react-google-maps with the prototype above on the same site shows a significant difference in rendering times:
When the user interacts with the map, the same scripts are still fetched and executed. But by deferring them until they’re needed, the browser's main thread is freed up to handle other tasks while the document continues to load. This will improve both Largest Contentful Paint and Interaction to Next Paint.
The chart and table below present a comparison of these two metrics when applying this optimization to a representative Next.js website: https://news-site-next-static.netlify.app/.
| Largest Contentful Paint | Total Blocking Time* | |
|---|---|---|
| News Site Next | 3.38s | 0.25s |
News Site Next with react-google-maps |
7.12s (+3.74s) | 0.97s (+0.72s) |
News Site Next with react-google-maps (Optimized) |
4.22s (+0.84s) | 0.44s (+0.19s) |
Test conditions: WebPageTest - Emulated 4G Connection, Chrome, Moto G4 (Median Results - 3 Runs)
*Total Blocking Time is used as a lab proxy here for Interaction to Next Paint
- 主要言語
- TypeScript
- スター
- 1.9k
- フォーク
- 195
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
visgl/react-google-maps のほかの issue
-
bug needs more info
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#1039 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
visgl/react-google-maps#918 · コメント 9 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
visgl/react-google-maps#905 ·
メンテナーはふだん 2 日以内に返信
-
google maps issue
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#889 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
visgl/react-google-maps#884 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
visgl/react-google-maps の issue をすべて見る
似ている issue
-
triage
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
mermaid-js/mermaid-live-editor#2053 ·
メンテナーはふだん 1 日以内に返信
-
factory
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
jessepollak/home#1455 ·
メンテナーはふだん 1 日以内に返信
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
lingdojo/kana-dojo#31227 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
appandflow/stim#1838 ·
メンテナーはふだん 1 日以内に返信