Internet usage on mobile have surpassed desktop
73% of mobile usage time spent on 3 top apps
Half of mobile users (in US) download 0 apps monthly
“Our biggest mistake was betting too much on HTML5.”
- Mark Zuckerberg, circa 2012
Is it still true now?
Smartphone's performance is getting a lot better.
However...
Smartphone users spend 10% of time on browser vs. 90% on apps.
Case Study
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#00796b">
manifest.json
{
“short_name": "Vue Shop",
"name": "Vue Shop - Mobile Shopping",
"icons": [
{
"src": "assets/logo-144.png",
"type": "image/png",
"sizes": "144x144"
},
{
"src": "assets/logo.png",
"type": "image/png",
"sizes": "192x192"
}
],
"start_url": "index.html",
"theme_color": "#00796b",
"background_color": "#b2dfdb",
"display": "standalone",
"orientation": "portrait"
}
navigator.geolocation.getCurrentPosition((position) => {
const pos = {
lat: position.coords.latitude,
lng: position.coords.longitude,
};
fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${pos.lat},${pos.lng}&key=${apiKey}`)
.then(/* Get location address from the result JSON */);
});
if (navigator.share) {
navigator.share({
title: `${this.item.title} - ${document.title}`,
text: this.item.description,
url: window.location.href,
})
.then(() => console.log('Successful share'))
.catch(error => console.log('Error sharing:', error));
}
Service Worker is a fresh new Web standard, and it requires HTTPS.
// register service worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js', {scope: '/'})
.then(function(reg) {
console.log('Registration succeeded. Scope is ' + reg.scope);
}).catch(function(error) {
console.log('Registration failed with ' + error);
});
}
// basic credential management API
navigator.credentials.get()
navigator.credentials.store()
navigator.credentials.requireUserMediation()
<label for="frmAddressS">Address</label>
<input autocomplete="shipping street-address" name="ship-address" required
id="frmAddressS" placeholder="123 Any Street">
<label for="frmCityS">City</label>
<input autocomplete="shipping locality" name="ship-city" required
id="frmCityS" placeholder="New York">
<label for="frmStateS">State</label>
<input autocomplete="shipping region" name="ship-state" required
id="frmStateS" placeholder="NY">
<label for="frmZipS">Zip</label>
<input autocomplete="shipping postal-code" name="ship-zip" required
id="frmZipS" placeholder="10011">
<label for="frmCountryS">Country</label>
<input autocomplete="shipping country" name="ship-country" required
id="frmCountryS" placeholder="USA">
// Create the autocomplete object, restricting the search to geographical location types.
let autoCompleteInput = document.getElementById('search-input');
autocomplete = new google.maps.places.Autocomplete(autoCompleteInput, { types: ['geocode'] });
// When the user selects an address from the dropdown, populate the address fields in the form.
autocomplete.addListener('place_changed', () => {
let place = autocomplete.getPlace();
// fill in the address form...
});