Professional Documents
Culture Documents
The Web - What It Has, What It Lacks and Where It Must Go: @robertnyman
The Web - What It Has, What It Lacks and Where It Must Go: @robertnyman
@robertnyman
and Where it Must Go
Our line of work
Face recognition
Experience
Trends
My role at Google
https://developers.google.com/android/
https://developers.google.com/ios/
https://developers.google.com/web/
My role at Google
My role at Google
My role at Google - https://medium.com/latest-from-google
The web as of today
The web vs. native
Tools & resources from Google
SLICE
Why do developers need a native app?
Monetization
Future of the web
The web
as of today
The web as of today
The web as of today
One billion
active users
Native is winning
Mobile-Friendly Test
Communications
& the web
Communications & the web
https://hangouts.google.com/
Microsoft Edge
Google Chrome
Mozilla Firefox
Opera 18
Android:
Google Chrome
Mozilla Firefox
Opera Mobile
Chrome OS
Firefox OS
WebRTC
Chrome DevTools
Web
Fundamentals
https://developers.google.com/web/fundamentals/
Web Fundamentals
Chrome Custom
Tabs
https://developer.chrome.com/multidevice/android/customtabs
Google influencers
Build instantly
engaging sites
and apps
without the need
for a mandatory
app download
SLICE
Linkable
SLICE
Indexable
SLICE
Composable
SLICE
Ephemeral
SLICE
Why do developers
need a native app?
Performance
Offline access
Notifications
Sensors
OS-specific features
From Brian Kennan
Offline access
Periodic background processing
Notifications
Sensors
OS-specific features
From Brian Kennan
Service Workers
It's a JavaScript Worker, so it can't access the DOM
directly. Instead responds to postMessages
Service Workers
HTTPS is Needed
Service Workers
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ',
registration.scope);
}).catch(function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
}
Service Workers
// The files we want to cache
var urlsToCache = [
'/',
'/styles/main.css',
'/script/main.js'
];
// Set the callback for the install step
self.addEventListener('install', function(event) {
// Perform install steps
});
1. Open a cache
2. Cache our files
3. Confirm whether all the required
assets are cached or not
Install callback
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
// Cache hit - return response
if (response) {
return response;
}
return fetch(event.request);
}
)
);
});
Push notifications
// Check the current Notification permission.
// If its denied, it's a permanent block until the
// user changes the permission
if (Notification.permission === 'denied') {
console.warn('The user has blocked notifications.');
return;
}
Push notifications
// Check if push messaging is supported
if (!('PushManager' in window)) {
console.warn('Push messaging isn\'t supported.');
return;
}
Push notifications
// We need the service worker registration to check for a subscription
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
// Do we already have a push message subscription?
serviceWorkerRegistration.pushManager.getSubscription()
.then(function(subscription) {
// Enable any UI which subscribes / unsubscribes from
// push messages.
var pushButton = document.querySelector('.js-push-button');
pushButton.disabled = false;
if (!subscription) {
// We aren't subscribed to push, so set UI
// to allow the user to enable push
return;
}
// Keep your server in sync with the latest subscriptionId
sendSubscriptionToServer(subscription);
// Set your UI to show they have subscribed for
// push messages
pushButton.textContent = 'Disable Push Messages';
isPushEnabled = true;
})
.catch(function(err) {
console.warn('Error during getSubscription()', err);
});
});
Push notifications
{
"name": "Push Demo",
"short_name": "Push Demo",
"icons": [{
"src": "images/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
}],
"start_url": "/index.html?homescreen=1",
"display": "standalone"
}
Push notifications
Add to
Homescreen
CacheApp
management
Install Banners
& whitelists
You have a web app manifest file
- Alex Russell
Progressive Apps
Monetization
Future of the web
WAWKI
-
Web as We Know It
nyman@google.com
@robertnyman