AMPで加速する
モバイルウェブアプリケーション
2017.09.24 HTML5 conf Room C 14:20-15:00
AMPで加速する
モバイルウェブアプリケーション (仮)
2017.09.24 HTML5 conf Room C 14:20-15:00
タイトルは雰囲気で決めた
とりあえず言いたいことを話すことに決めました
DISCLAIMER
goo.gl/AktJSs
自己紹介
今日の流れ
歴史
広告モデルがオープンウェブを支えてきた事実は認めよう
メディア系サイトに必要な要素再考
広告の表示が静的なコンテンツの表示を妨げている
document.write()
歴史的経緯から仕方がない側面がある
静的ページを素早く表示する欲求
自力でチューニングする事が難しい人向けに簡単な仕組みを提供する必要性
Accerelated Mobile Pages
ページの高速化をするには
AMPの構成要素
AMP HTML
c.f. Web Componentsについて
16:20-17:00の泉水さんのセッションを見ましょう
AMP HTML
<!doctype html>
<html ⚡>
<head>
<title>Hello, AMPs</title>
<link rel="canonical" href="http://your.com/page1.html" />
<style amp-boilerplate>...</style>
<script async src="https://cdn.ampproject.org/v0.js"></script>
</head>
<body>
<h1>Welcome to the mobile web</h1>
<amp-img height="300" width="400" src="hoge.png"></amp-img>
</body>
</html>
AMP HTMLの他の制約
AMP JS
高速化はAMPチームが担保。使用者は読み込んでおくだけで良い。
AMP JS
c.f. PRPLパターン
AMP JS
Header
Logo
Responsive hero image
Headline
Article text
Image�in article
Some more text
Ad
“Above the Fold”
Prerendered
“Below the Fold”
Not Prerendered
AMP JS (例: amp-adでの広告の表示)
広告は3p.jsで登録される
registrations[id] = draw // 3p/3p.js, in register(id, draw) function
draw3pがremote.html/frame.htmlというiframe内のHTMLの中で呼ばれる
run(type, win, data) // 3p/3p.js
const fn = registrations[id] // 3p/3p.js, in run(type, win, data) function
fn(win, data)
frame.htmlは次のような関数を通過していく
AmpAd3PImpl.layoutCallback() // extensions/amp-ad/0.1/amp-ad-3p-impl.js
getIframe(parentWindow, parentElement, opt_type, opt_context) // src/3p-frame.js
getBootstrapBaseUrl(parentWindow, opt_strictForUnitTest) // src/3p-frame.js
getDefatulaBootstrapBaseUrl(parentWindow) // src/3p-frame.js
AMP Cache
AMP Cache
AMP Cache(Google Global Cache)
Web server
Edge server
Edge server
Edge server
Edge server
Edge server
Edge server
Edge server
※これは概念図です
AMP Cache(HTTP/2)
ロードマップ
新しい機能は日々追加されている
DEMO
amp-sidebar
amp-carousel
amp-carousel
amp-lightbox
amp-bind
「AMPとPWA」に関して
AMPとPWAの共存
amp-install-serviceworker
AMP as PWA
AMP in PWA
ShadowReader
まとめ
Q&A