What’s New in Chrome
and the Web
2019
I/O Extended Cebu
Arnelle Balane
Software Developer, Newlogic @arnellebalane
Slide 2
Slide 2 text
Load images only when they
are about to scroll into view.
Native
Lazy Loading
Slide 3
Slide 3 text
The "loading" attribute
Allows browsers do defer loading offscreen images
and iframes until the user scrolls near them.
Supports three possible values: auto, lazy, and eager.
Slide 4
Slide 4 text
The browser decides whether to lazy load or not.
In Chrome, this doesn’t lazy load… yet.
Slide 5
Slide 5 text
Explicitly tells the browser to lazy load the image.
Slide 6
Slide 6 text
Explicitly tells the browser to load the image right away.
Slide 7
Slide 7 text
Progressive Enhancement
Slide 8
Slide 8 text
if ('loading' in HTMLImageElement.prototype) {
const images =
document.querySelectorAll('img[data-src]');
images.forEach(image => {
image.src = image.dataset.src;
});
}
Slide 9
Slide 9 text
if ('loading' in HTMLImageElement.prototype) {
const images =
document.querySelectorAll('img[data-src]');
images.forEach(image => {
image.src = image.dataset.src;
});
}
Slide 10
Slide 10 text
if ('loading' in HTMLImageElement.prototype) {
const images =
document.querySelectorAll('img[data-src]');
images.forEach(image => {
image.src = image.dataset.src;
});
}
Slide 11
Slide 11 text
if ('loading' in HTMLImageElement.prototype) {
const images =
document.querySelectorAll('img[data-src]');
images.forEach(image => {
image.src = image.dataset.src;
});
}
Slide 12
Slide 12 text
if ('loading' in HTMLImageElement.prototype) {
const images =
document.querySelectorAll('img[data-src]');
images.forEach(image => {
image.src = image.dataset.src;
});
} else {
// Fallback to using a lazy loading library,
// e.g. lazysizes
}
Slide 13
Slide 13 text
Works with responsive images
( element, srcset attribute)
Doesn’t support background images.
Native Lazy Loading
Slide 14
Slide 14 text
Behind a flag in Chrome 75
chrome://flags
#enable-lazy-image-loading
#enable-lazy-frame-loading
Native Lazy Loading
JavaScript standard library
for the Web.
Built-in Modules
Slide 30
Slide 30 text
Browsers have shipped and
nomodule attribute.
We provide the definitions for the modules, and they
need to be downloaded to be used.
Slide 31
Slide 31 text
Like regular JavaScript modules, but already ship
with the browser and so don’t need to be
downloaded.
Need to be used inside .
Built-in Modules
Slide 32
Slide 32 text
Asynchronous key-value store, having JavaScript
Map-like API: set(), get(), delete().
Keys and values don’t have to be strings, unlike
LocalStorage.
KV Storage
Slide 33
Slide 33 text
import { storage } from 'std:kv-storage';
KV Storage
Built-in Modules, KV Storage,
and Import Maps
Behind a flag in Chrome 74
chrome://flags
#enable-experimental-web-platform-features
Slide 47
Slide 47 text
Origin Trial is active until September 4, 2019
https://developers.chrome.com/origintrials
/#/register_trial/3175037737296199681
Built-in Modules, KV Storage,
and Import Maps
Slide 48
Slide 48 text
Resources
https://developers.google.com/web/updates
/2019/03/kv-storage
Built-in Modules, KV Storage,
and Import Maps
Slide 49
Slide 49 text
New
Media Queries
Allows authors to query values
or features of the device that’s
rendering the page.
Slide 50
Slide 50 text
Brings users’ “reduced motion”
preferences to the Web.
Possible values:
no-preference and reduce
prefers-reduced-motion
Slide 51
Slide 51 text
prefers-reduced-motion
Use case:
When user prefers reduced motion, remove
non-essential animations and transitions, parallax
scrolling, etc.
@media (prefers-color-scheme: dark) {
body {
background-color: black;
}
}
Dark mode
Slide 58
Slide 58 text
Respecting user preference is key.
More are coming:
prefers-reduced-transparency, prefers-contrast, and
inverted-colors
New Media Queries
Slide 59
Slide 59 text
prefers-reduced-motion
Enabled by default in Chrome 74
prefers-color-scheme
Enabled by default in Chrome 76
New Media Queries
Slide 60
Slide 60 text
Resources
https://developers.google.com/web/updates
/2019/03/prefers-reduced-motion
https://web.dev/prefers-color-scheme
New Media Queries
Slide 61
Slide 61 text
No content
Slide 62
Slide 62 text
The Web is now 30 years old!
Slide 63
Slide 63 text
Complex, dynamic,
interactive Web
applications
✨
Simple, static
Web pages
Slide 64
Slide 64 text
Web apps that look, feel,
and behave like native apps.
Slide 65
Slide 65 text
Web apps that look, feel, and
behave like native apps.
Are they as capable?
Slide 66
Slide 66 text
Web apps still lag behind native
apps in terms of capabilities.
Slide 67
Slide 67 text
Project Fugu
Slide 68
Slide 68 text
Closing the capability gap between native and Web,
while preserving everything that’s great with the Web.
New standardized APIs that will unlock powerful
capabilities for the Web.
Project Fugu
Slide 69
Slide 69 text
Share to and receive shares
through the system share
sheet.
Web Share and
Web Share Target
Slide 70
Slide 70 text
if ('share' in navigator) {
const shareOptions = {
title: 'What is New in Chrome and the Web',
text: 'Cool stuff cool stuff cool stuff!',
url: 'https://iox.gdgcebu.org/'
};
await navigator.share(shareOptions);
}
Slide 71
Slide 71 text
if ('share' in navigator) {
const shareOptions = {
title: 'What is New in Chrome and the Web',
text: 'Cool stuff cool stuff cool stuff!',
url: 'https://iox.gdgcebu.org/'
};
await navigator.share(shareOptions);
}
Slide 72
Slide 72 text
if ('share' in navigator) {
const shareOptions = {
title: 'What is New in Chrome and the Web',
text: 'Cool stuff cool stuff cool stuff!',
url: 'https://iox.gdgcebu.org/'
};
await navigator.share(shareOptions);
}
Slide 73
Slide 73 text
if ('share' in navigator) {
const shareOptions = {
title: 'What is New in Chrome and the Web',
text: 'Cool stuff cool stuff cool stuff!',
url: 'https://iox.gdgcebu.org/'
};
await navigator.share(shareOptions);
}
Slide 74
Slide 74 text
if ('share' in navigator) {
const shareOptions = {
title: 'What is New in Chrome and the Web',
text: 'Cool stuff cool stuff cool stuff!',
url: 'https://iox.gdgcebu.org/'
};
await navigator.share(shareOptions);
} else {
// Fallback to traditional share implementations.
}
const shareOptions = {
files: [file]
};
if (navigator.canShare(shareOptions)) {
shareOptions.title = 'What is New in Chrome?';
shareOptions.text = 'Cool stuff cool stuff!';
shareOptions.url = 'https://iox.gdgcebu.org/';
await navigator.share(shareOptions);
}
Slide 81
Slide 81 text
Title, text, and URL
Enabled by default in Chrome 61
With files support
Enabled by default in Chrome 75
Web Share API
Slide 82
Slide 82 text
Resources
https://wicg.github.io/web-share/level-2/
https://developers.google.com/web/updates
/2016/09/navigator-share
https://github.com/WICG/web-share/blob/master
/docs/explainer.md
Web Share API
Slide 83
Slide 83 text
Title, text, and URL
Enabled by default in Chrome 71
With files support
Enabled by default in Chrome 76
Web Share Target API
Slide 84
Slide 84 text
Resources
https://wicg.github.io/web-share-target/
https://github.com/WICG/web-share-target
/blob/master/docs/explainer.md
https://developers.google.com/web/updates
/2018/12/web-share-target
Web Share Target API
Slide 85
Slide 85 text
Programmatic access to the
system clipboard.
Async
Clipboard API
Slide 86
Slide 86 text
if ('clipboard' in navigator) {
await navigator.clipboard.writeText('Hello World');
const text = await navigator.clipboard.readText();
}
Text support
Slide 87
Slide 87 text
await navigator.clipboard.write([
new ClipboardItem({'image/png': blob})
]);
Image support
Slide 88
Slide 88 text
canvas.toBlob(async blob => {
await navigator.clipboard.write([
new ClipboardItem({'image/png': blob})
]);
});
Image support
Text-only
Enabled by default in Chrome 66
With image support
Enabled by default in Chrome 76
Async Clipboard API
Slide 91
Slide 91 text
Resources
https://w3c.github.io/clipboard-apis/
https://developers.google.com/web/updates
/2018/03/clipboardapi
Async Clipboard API
Slide 92
Slide 92 text
Set subtle app alerts in places
like the home screen, dock,
etc.
Badging API
Slide 93
Slide 93 text
window.Badge.set(12);
window.Badge.clear();
Badging API
Slide 94
Slide 94 text
No content
Slide 95
Slide 95 text
No content
Slide 96
Slide 96 text
Behind a flag in Chrome 73
chrome://flags
#enable-experimental-web-platform-features
Badging API
Slide 97
Slide 97 text
Badging API
Origin Trial is active until October 15, 2019
https://developers.chrome.com/origintrials
/#/view_trial/3175037737296199681
Slide 98
Slide 98 text
Resources
https://github.com/WICG/badging/blob/master/explainer.md
https://developers.google.com/web/updates
/2018/12/badging-api
Badging API
Slide 99
Slide 99 text
Prevent the screen from
turning off or the device from
going to sleep.
Wake Lock API
Slide 100
Slide 100 text
if ('getWakeLock' in navigator) {
const wakeLock =
await navigator.getWakeLock('screen');
}
Get a wake lock
Slide 101
Slide 101 text
if ('getWakeLock' in navigator) {
const wakeLock =
await navigator.getWakeLock('screen');
}
Get a wake lock
Slide 102
Slide 102 text
if ('getWakeLock' in navigator) {
const wakeLock =
await navigator.getWakeLock('system');
}
Get a wake lock
Slide 103
Slide 103 text
let wakeLockRequest = wakeLock.createRequest();
Activate a wake lock
Slide 104
Slide 104 text
wakeLockRequest.cancel();
wakeLockRequest = null;
Deactivate a wake lock
Slide 105
Slide 105 text
Behind a flag in Chrome 71
chrome://flags
#enable-experimental-web-platform-features
Wake Lock API
Slide 106
Slide 106 text
Resources
https://w3c.github.io/wake-lock/
https://developers.google.com/web/updates
/2018/12/wakelock
Wake Lock API
Slide 107
Slide 107 text
Detect faces, text, and
barcodes / QR codes from
images.
Shape
Detection API
Slide 108
Slide 108 text
No content
Slide 109
Slide 109 text
Behind a flag in Chrome 57
chrome://flags
#enable-experimental-web-platform-features
Shape Detection API
Slide 110
Slide 110 text
Resources
https://wicg.github.io/shape-detection-api/
https://github.com/WICG/shape-detection-api/
Shape Detection API
Slide 111
Slide 111 text
Communicate with nearby
Bluetooth Low Energy (BLE)
devices.
Web
Bluetooth API
Slide 112
Slide 112 text
Enabled by default in Chrome 56
Resources
https://webbluetoothcg.github.io/web-bluetooth/
https://developers.google.com/web/updates
/2015/07/interact-with-ble-devices-on-the-web
Web Bluetooth API
Slide 113
Slide 113 text
Communicate with
microcontrollers and other
serial devices.
Web Serial API
Slide 114
Slide 114 text
Create experiences that
involve files from the local file
system.
Native
File System API
Slide 115
Slide 115 text
Simplify use of locally installed
fonts that are only available
on the desktop.
Font Access API
Slide 116
Slide 116 text
Provide Web apps with
contact info from the contacts
list.
Contact
Picker API
Slide 117
Slide 117 text
Be notified when SMS
messages (following a format
convention) are delivered to
the device.
SMS Receiver API
Slide 118
Slide 118 text
Show notifications based on
triggers, e.g. time-based,
location-based, etc.
Notification
Triggers
Slide 119
Slide 119 text
Project Fugu
Slide 120
Slide 120 text
Try them out!
Participate in Origin Trials
Share your thoughts, provide feedback
What can we do?