第49回html5勉強会 google i/o 2014サマリー
DESCRIPTION
Google I/O 2014サマリーTRANSCRIPT
Google I/O 2014サマリー
agektmr@の代理のtakoratta@
Google I/Oとは
ご存知だと思うので、駆け足で。
Google Confidential and Proprietary
Google I/O 2014● 6月25日、26日にサンフランシスコで開催
● 約6,000人が参加
● 約75のセッション
Google Confidential and Proprietary
Google Confidential and Proprietary
Google Confidential and Proprietary
Google Confidential and Proprietary
Google Confidential and Proprietary
Google Confidential and Proprietary
Google Confidential and Proprietary
Google Confidential and Proprietary
Questions ?Ok, now go build something awesome!
https://plus.google.com/u/0/+AkihitoFujii/posts/Lyu5wRYHd9d?pid=6029333485917463794&oid=104976800917577721821
Google Confidential and Proprietary
Google Confidential and Proprietary
Google I/Oの基調講演を現地で参加出来ない開発者の方がライブストリームで見れるイベントを世界中で開催
Google Confidential and Proprietary
Google I/OでのHTML5関連のセッション
いくつか紹介
Google Confidential and Proprietary
Chrome/HTML5関連の話
● Perf Culture● Polymer and the Web Components revolution● Polymer and Web Components change everything you know about
Web development● Bridging the gap between the web and apps● How we built Chrome Dev Editor with the Chrome platform● Making the mobile web fast, feature-rich, and beautiful● Mobile Web performance auditing● Making music mobile with the Web● Developing across Devices - Chrome DevTools in 2014
Google Confidential and Proprietary
Chrome/HTML5関連の話
● Perf Culture● Polymer and the Web Components revolution● Polymer and Web Components change everything you know about
Web development● Bridging the gap between the web and apps● How we built Chrome Dev Editor with the Chrome platform● Making the mobile web fast, feature-rich, and beautiful● Mobile Web performance auditing● Making music mobile with the Web● Developing across Devices - Chrome DevTools in 2014
次の2つのセッションをお聴きください。
Polymer Web Components
Google Confidential and Proprietary
Chrome/HTML5関連の話
● Perf Culture● Polymer and the Web Components revolution● Polymer and Web Components change everything you know about
Web development● Bridging the gap between the web and apps● How we built Chrome Dev Editor with the Chrome platform● Making the mobile web fast, feature-rich, and beautiful● Mobile Web performance auditing● Making music mobile with the Web● Developing across Devices - Chrome DevTools in 2014
ServiceWorker
Google Confidential and Proprietary
Chrome/HTML5関連の話
● Perf Culture● Polymer and the Web Components revolution● Polymer and Web Components change everything you know about
Web development● Bridging the gap between the web and apps● How we built Chrome Dev Editor with the Chrome platform● Making the mobile web fast, feature-rich, and beautiful● Mobile Web performance auditing● Making music mobile with the Web● Developing across Devices - Chrome DevTools in 2014
Chrome Dev Editor
Google Confidential and Proprietary
Chrome/HTML5関連の話
● Perf Culture● Polymer and the Web Components revolution● Polymer and Web Components change everything you know about
Web development● Bridging the gap between the web and apps● How we built Chrome Dev Editor with the Chrome platform● Making the mobile web fast, feature-rich, and beautiful● Mobile Web performance auditing● Making music mobile with the Web● Developing across Devices - Chrome DevTools in 2014
DevTools
Bridging the gap between the web and apps オフラインファースト ServiceWorker
Google Confidential and Proprietary
話者
Google Confidential and Proprietary
I/O Bytes - The ServiceWorker: The network layer is yours to own
Google Confidential and Proprietary
動機
Google Confidential and Proprietary
ネットワークの効率的な活用
Google Confidential and Proprietary
オフラインって言っても
Google Confidential and Proprietary
完全にオフラインという場合だけではなくて
Google Confidential and Proprietary
不安定(辺境の地とか)
Google Confidential and Proprietary
しょっちゅう切れる
(お金のない地下鉄とか)
Google Confidential and Proprietary
なぜかわからないけど自分だけつながらない(呪われているとか)
Google Confidential and Proprietary
とか、あるわけですが、
Google Confidential and Proprietary
今はそのような異なる状況に対応したWebアプリを書くのがとても難しい
Google Confidential and Proprietary
ネイティブアプリの振る舞い
ネットワーク接続が必要なアプリであったとしても、
● キャッシュからリソースをフェッチし、即座に表示
● その間/その後すぐにネットワークに接続
● たとえ、ネットワークに接続できなかったとしても、ユーザーに気づかせないで動作するアプリさえある(=ユーザーの操作を邪魔しない)
Google Confidential and Proprietary
オフラインファースト
Google Confidential and Proprietary
Application Cache (AppCache) というものがありますが、
Google Confidential and Proprietary
Google Confidential and Proprietary
AppCacheの問題点
● 複雑
● きめ細かい処理が不得手
● JavaScriptからの制御が面倒
Google Confidential and Proprietary
Google Confidential and Proprietary
ServiceWorker
● 高度なオフライン機能
● WebサイトからインストールされたJavaScriptが独立したWorkerスレッドとして動作し、Webサイトからのイベントハンドリングを実現○ Webページを閉じてもバックグラウンドで動作○ ただし、HTTPSが必須
● 頭の良い(+JSから制御可能な)“In-browser HTTP proxy”
Google Confidential and Proprietary
ServiceWorker
Browser
ServiceWorker Caches
Page PagePage
Internet
Google Confidential and Proprietary
インストール(アプリ側 / app.js)
if (‘serviceWorker’ in navigator) {
navigator.serviceWorker.register(
‘/trained-to-thrill/static/js/sw.js’,
{scope: ‘/trained-to-thrill/*’}
).then(success, failure);
}
Google Confidential and Proprietary
sw.jsの役割
Browser
ServiceWorker Caches
Page PagePage
Internet
● 別スレッドで動作● DOMアクセスは無し● ページとは独立した処理を
行う● ローディングの制御● 1つのServiceWorkderで複
数のページの制御が可能● キャッシュの制御
頭の良い(+JSから制御可能な)“In-browser HTTP proxy”
Google Confidential and Proprietary
インストール(ServiceWorker側 / sw.js)
this.addEventListener('install', function(event) {
event.waitUntil(somePromise);
});
Google Confidential and Proprietary
インストール(ServiceWorker側 / sw.js)
this.addEventListener('install', function(event) { event.waitUntil( caches.create('static-v1').then(function(cache) { return cache.add({ ‘/trained-to-thrill/’, ‘/trained-to-thrill/fallback.html’, ‘/trained-to-thrill/static/all.css’, ‘/trained-to-thrill/static/all.js’, ‘/trained-to-thrill/static/lego.svg’ }); }) );});
Google Confidential and Proprietary
Fetchイベントの処理(ServiceWorker側 / sw.js)
this.addEventListener('fetch’, function(event) { console.log(event.request);});
i.e)event.request.urlevent.request.methodevent.request.headers
Google Confidential and Proprietary
Fetchイベントの処理(ServiceWorker側 / sw.js)
this.addEventListener('fetch’, function(event) { event.respondWith(response);});
Google Confidential and Proprietary
Fetchイベントの処理(ServiceWorker側 / sw.js)
this.addEventListener('fetch’, function(event) { event.respondWith( new Response(‘Hello ServiceWorker!’) );});
Google Confidential and Proprietary
キャッシュの利用(ServiceWorker側 / sw.js)
this.addEventListener('fetch’, function(event) { event.respondWith( caches.match(event.request) );});
Google Confidential and Proprietary
キャッシュの利用(ServiceWorker側 / sw.js)
this.addEventListener('fetch’, function(event) { event.respondWith( caches.match(event.request).catch(function() return event.default(); }) );});
Google Confidential and Proprietary
キャッシュの利用(ServiceWorker側 / sw.js)
this.addEventListener('fetch’, function(event) { event.respondWith( caches.match(event.request).catch(function() return event.default(); }).catch(function() { return caches.match( ‘/trained-to-thrill/fallback.html’);...
Google Confidential and Proprietary
AppCacheで同じことを行った場合
CACHE MANIFEST/trained-to-thrill/static/all.css/trained-to-thrill/static/all.js/trained-to-thrill/static/lego.svg
NETWORK:*
FALLBCK:/trained-to-thrill/fallback.html
Google Confidential and Proprietary
AppCacheで同じことを行った場合
CACHE MANIFEST/trained-to-thrill/static/all.css/trained-to-thrill/static/all.js/trained-to-thrill/static/lego.svg
NETWORK:*
FALLBCK:/trained-to-thrill/fallback.html
Google Confidential and Proprietary
ネットワークの接続状況に応じた処理
navigator.onLineに頼らない、ServiceWorkerによるキャッシュの有効活用が必要。
Google Confidential and Proprietary
参考資料
ブラウザの対応状況 → is ServiceWorker ready?
Chromiumプロジェクトページ → http://www.chromium.org/blink/serviceworker
How we built Chrome Dev Editor with the Chrome platform
Chrome Dev Editor (CDE)
Google Confidential and Proprietary
Google Confidential and Proprietary
Google Confidential and Proprietary
Chrome Dev Editor● Dart / Polymerで開発されたChrome上で動作するエ
ディタ● Chrome Webストアから入手可能● オープンソース
○ https://github.com/dart-lang/chromedeveditor/ ● Gitとの連携可能
○ git clone○ git branch○ git checkout○ など
● ダイレクトモバイルデバッグ
Google Confidential and Proprietary
Chrome Dev Editor
● Dart Webアプリ、JavaScript Webアプリ、JavaScript/Polymer Webアプリ、Web Starter Kit, JavaScript Chromeアプリ、JavaScript Polymer CustomElementの開発が可能(テンプレートが用意されている)
● 作成したChrome WebアプリをChrome Webストアに登録可能
● ビルトインWebサーバー● マークダウンプレビュー
Developing across Devices - Chrome DevTools in 2014
DevTools
Google Confidential and Proprietary
モバイルWeb開発に役立つ!Chrome DevToolsの新機能「デバイスモード」 | HTML5Experts.jp
Graphic by Luke W. Used with permission.
Google Confidential and Proprietary
Design Develop Iterate
Google Confidential and Proprietary
Design Responsive Layout
Google Confidential and Proprietary
Develop Rich Emulation
Google Confidential and Proprietary
Iterate Remote Debugging
Google Confidential and Proprietary
• Plug & Play
• Same powerful features
• Screencast your device
• Port forwarding· for local development
• Device Presets for most popular devices
• Rich viewport emulation
• Sensor emulation· Touch, Geolocation,
Accelerometer
• Network throttling and offline
• Rich representation of media queries
• Style filtering
• Media query editing
• Plays well with inline emulation
Responsive layouts Rich Emulation Remote debugging
Google Confidential and Proprietary
Google I/O
THANK YOU