Web APIs you might not know about

Web APIs you might not know about

Sasha Shynkevich (@neesoglasnaja)

Gravity Falls © Disney

Hi, my name is Sasha!

What does "Web APIs" mean?

What we have to deal with in browser

Web APIs

Web APIs | MDN

DOM and styles manipulations

How to detect a page zoom?

Simple browser zoom detect with jquery #codevember
Visual vs. Layout Viewport Demo

VisualViewport API

VisualViewport = {
  // Read-only
  offsetLeft
  offsetTop
  pageLeft
  pageTop
  width  
  height
  scale
}
 
// How to get a page zoom value*
const scale = VisualViewport.scale
Example with hide on zoom
Caniuse — VisualViewport API

DOM and styles manipulations

DOM
CSS Counter Styles
CSS Font Loading API
CSS Painting API
CSS Typed OM
CSSOM
HTML Drag and Drop API
Intersection Observer API
Page Visibility API
Pointer events
Pointer Lock API
Resize Observer API
Touch events
Visual Viewport API

DOM and styles manipulations

DOM
CSS Counter Styles
CSS Font Loading API
CSS Painting API
CSS Typed OM
CSSOM
HTML Drag and Drop API
Intersection Observer API
Page Visibility API
Pointer events
Pointer Lock API
Resize Observer API
Touch events
Visual Viewport API

DOM and styles manipulations

DOM
CSS Counter Styles
CSS Font Loading API
CSS Painting API
CSS Typed OM
CSSOM
HTML Drag and Drop API
Intersection Observer API
Page Visibility API
Pointer events
Pointer Lock API
Resize Observer API
Touch events
Visual Viewport API

DOM and styles manipulations

DOM
CSS Counter Styles
CSS Font Loading API
CSS Painting API
CSS Typed OM
CSSOM
HTML Drag and Drop API
Intersection Observer API
Page Visibility API
Pointer events
Pointer Lock API
Resize Observer API
Touch events
Visual Viewport API

DOM and styles manipulations

DOM
CSS Counter Styles
CSS Font Loading API
CSS Painting API
CSS Typed OM
CSSOM
HTML Drag and Drop API
Intersection Observer API
Page Visibility API
Pointer events
Pointer Lock API
Resize Observer API
Touch events
Visual Viewport API

DOM and styles manipulations

DOM
CSS Counter Styles
CSS Font Loading API
CSS Painting API
CSS Typed OM
CSSOM
HTML Drag and Drop API
Intersection Observer API
Page Visibility API
Pointer events
Pointer Lock API
Resize Observer API
Touch events
Visual Viewport API

Data transferring and network

How to communicate between tabs while there is no Internet connection?

Broadcast Channel API

Demo - BroadcastChannel

Broadcast Channel API

const bc = new BroadcastChannel('test_channel')
bc.postMessage('This is a test message.')
bc.onmessage = function (ev) { ... }
bc.close();
Caniuse — BroadcastChannel

Data transferring and network

Background Fetch API
Beacon API
Broadcast Channel API
Content Index API
Channel Messaging API
Fetch API
History API
Network Information API
Service Worker API
Server-sent events
Streams API
Web Periodic Background Synchronization API
URL API
WebSockets
XMLHttpRequest

Data transferring and network

Background Fetch API
Beacon API
Broadcast Channel API
Content Index API
Channel Messaging API
Fetch API
History API
Network Information API
Service Worker API
Server-sent events
Streams API
Web Periodic Background Synchronization API
URL API
WebSockets
XMLHttpRequest

Data transferring and network

Background Fetch API
Beacon API
Broadcast Channel API
Content Index API
Channel Messaging API
Fetch API
History API
Network Information API
Service Worker API
Server-sent events
Streams API
Web Periodic Background Synchronization API
URL API
WebSockets
XMLHttpRequest

Data transferring and network

Background Fetch API
Beacon API
Broadcast Channel API
Content Index API
Channel Messaging API
Fetch API
History API
Network Information API
Service Worker API
Server-sent events
Streams API
Web Periodic Background Synchronization API
URL API
WebSockets
XMLHttpRequest

Data transferring and network

Background Fetch API
Beacon API
Broadcast Channel API
Content Index API
Channel Messaging API
Fetch API
History API
Network Information API
Service Worker API
Server-sent events
Streams API
Web Periodic Background Synchronization API
URL API
WebSockets
XMLHttpRequest

Data transferring and network

Background Fetch API
Beacon API
Broadcast Channel API
Content Index API
Channel Messaging API
Fetch API
History API
Network Information API
Service Worker API
Server-sent events
Streams API
Web Periodic Background Synchronization API
URL API
WebSockets
XMLHttpRequest

Media

How to detect QR-codes from a browser?

Detect QR-code

Barcode Detection Using the Shape Detection API

Barcode Detection API

const barcodeDetector = new BarcodeDetector();
 barcodeDetector.detect(image)
  .then(barcodes => { ... })
  .catch(e => { ... });
Caniuse — BarcodeDetector API

Media

Barcode Detection API
Canvas API
Encrypted Media Extensions API
Fullscreen API
Media Capabilities API
Media Session API
Media Source API
Media Stream
MediaStream Recording API
MediaStream Image Capture API
Picture-in-Picture API
Presentation API
Screen Capture API
Screen Wake Lock API
Web Animations API
Web Audio API
WebGL
WebRTC API
Web Speech API
Web Video Text Tracks Format
WebVR API WebXR Device API

Media

Barcode Detection API
Canvas API
Encrypted Media Extensions API
Fullscreen API
Media Capabilities API
Media Session API
Media Source API
Media Stream
MediaStream Recording API
MediaStream Image Capture API
Picture-in-Picture API
Presentation API
Screen Capture API
Screen Wake Lock API
Web Animations API
Web Audio API
WebGL
WebRTC API
Web Speech API
Web Video Text Tracks Format
WebVR API WebXR Device API

Media

Barcode Detection API
Canvas API
Encrypted Media Extensions API
Fullscreen API
Media Capabilities API
Media Session API
Media Source API
Media Stream
MediaStream Recording API
MediaStream Image Capture API
Picture-in-Picture API
Presentation API
Screen Capture API
Screen Wake Lock API
Web Animations API
Web Audio API
WebGL
WebRTC API
Web Speech API
Web Video Text Tracks Format
WebVR API WebXR Device API

Media

Barcode Detection API
Canvas API
Encrypted Media Extensions API
Fullscreen API
Media Capabilities API
Media Session API
Media Source API
Media Stream
MediaStream Recording API
MediaStream Image Capture API
Picture-in-Picture API
Presentation API
Screen Capture API
Screen Wake Lock API
Web Animations API
Web Audio API
WebGL
WebRTC API
Web Speech API
Web Video Text Tracks Format
WebVR API WebXR Device API

Media

Barcode Detection API
Canvas API
Encrypted Media Extensions API
Fullscreen API
Media Capabilities API
Media Session API
Media Source API
Media Stream
MediaStream Recording API
MediaStream Image Capture API
Picture-in-Picture API
Presentation API
Screen Capture API
Screen Wake Lock API
Web Animations API
Web Audio API
WebGL
WebRTC API
Web Speech API
Web Video Text Tracks Format
WebVR API WebXR Device API

Media

Barcode Detection API
Canvas API
Encrypted Media Extensions API
Fullscreen API
Media Capabilities API
Media Session API
Media Source API
Media Stream
MediaStream Recording API
MediaStream Image Capture API
Picture-in-Picture API
Presentation API
Screen Capture API
Screen Wake Lock API
Web Animations API
Web Audio API
WebGL
WebRTC API
Web Speech API
Web Video Text Tracks Format
WebVR API WebXR Device API

Media

Barcode Detection API
Canvas API
Encrypted Media Extensions API
Fullscreen API
Media Capabilities API
Media Session API
Media Source API
Media Stream
MediaStream Recording API
MediaStream Image Capture API
Picture-in-Picture API
Presentation API
Screen Capture API
Screen Wake Lock API
Web Animations API
Web Audio API
WebGL
WebRTC API
Web Speech API
Web Video Text Tracks Format
WebVR API WebXR Device API

Media

Barcode Detection API
Canvas API
Encrypted Media Extensions API
Fullscreen API
Media Capabilities API
Media Session API
Media Source API
Media Stream
MediaStream Recording API
MediaStream Image Capture API
Picture-in-Picture API
Presentation API
Screen Capture API
Screen Wake Lock API
Web Animations API
Web Audio API
WebGL
WebRTC API
Web Speech API
Web Video Text Tracks Format
WebVR API WebXR Device API

Devices

How to make your phone buzzing?

Let's roll the dice!

Vibration API

if ("vibrate" in navigator) {
  ...
  navigator.vibrate(200) // one-time vibro
  navigator.vibrate([100,30,100,30,...]) // sequential vibro
  ...
}
Caniuse — Vibration API

Devices

Clipboard API
Gamepad API
Geolocation API
Notifications API
Permissions API
Push API
Battery Status API Proximity Events
Sensor APIs
Vibration API
Web Bluetooth API
WebHID API
Web MIDI API

Devices

Clipboard API
Gamepad API
Geolocation API
Notifications API
Permissions API
Push API
Battery Status API Proximity Events
Sensor APIs
Vibration API
Web Bluetooth API
WebHID API
Web MIDI API

Devices

Clipboard API
Gamepad API
Geolocation API
Notifications API
Permissions API
Push API
Battery Status API Proximity Events
Sensor APIs
Vibration API
Web Bluetooth API
WebHID API
Web MIDI API

Devices

Clipboard API
Gamepad API
Geolocation API
Notifications API
Permissions API
Push API
Battery Status API Proximity Events
Sensor APIs
Vibration API
Web Bluetooth API
WebHID API
Web MIDI API

Devices

Clipboard API
Gamepad API
Geolocation API
Notifications API
Permissions API
Push API
Battery Status API Proximity Events
Sensor APIs
Vibration API
Web Bluetooth API
WebHID API
Web MIDI API

Devices

Clipboard API
Gamepad API
Geolocation API
Notifications API
Permissions API
Push API
Battery Status API Proximity Events
Sensor APIs
Vibration API
Web Bluetooth API
WebHID API
Web MIDI API

Devices

Clipboard API
Gamepad API
Geolocation API
Notifications API
Permissions API
Push API
Battery Status API Proximity Events
Sensor APIs
Vibration API
Web Bluetooth API
WebHID API
Web MIDI API

Data management

How to disable unsafe code execution for user-created content?

sanitize-html

Sanitize unsafe text

Caniuse — Sanitizer API

Can I get access to user's contacts as if it's a mobile app?

Contact Picker API Demo

Contact Picker API

const supported = ('contacts' in navigator
   && 'ContactsManager' in window);
const props = ['name', 'email', 'tel', 'address', 'icon'];
const opts = { multiple: true };
navigator.contacts.select(props, opts)
  .then(contacts => { ... })
  .catch(e => { ... })
ContactsManager - Web APIs | MDN

Data management

Background Tasks API
Console API
Contact Picker API
Credential Management API
Encoding API
HTML Sanitizer API
File and Directory Entries API
File System Access API
Frame Timing API
IndexedDB API
Long Tasks API
Navigation Timing API
Performance API
Performance Timeline
Resource Timing API
Payment Request API
Storage Access API
Storage API
Web Authentication API
Web Crypto API
Web Storage API
Web Workers API

Data management

Background Tasks API
Console API
Contact Picker API
Credential Management API
Encoding API
HTML Sanitizer API
File and Directory Entries API
File System Access API
Frame Timing API
IndexedDB API
Long Tasks API
Navigation Timing API
Performance API
Performance Timeline
Resource Timing API
Payment Request API
Storage Access API
Storage API
Web Authentication API
Web Crypto API
Web Storage API
Web Workers API

Data management

Background Tasks API
Console API
Contact Picker API
Credential Management API
Encoding API
HTML Sanitizer API
File and Directory Entries API
File System Access API
Frame Timing API
IndexedDB API
Long Tasks API
Navigation Timing API
Performance API
Performance Timeline
Resource Timing API
Payment Request API
Storage Access API
Storage API
Web Authentication API
Web Crypto API
Web Storage API
Web Workers API

Data management

Background Tasks API
Console API
Contact Picker API
Credential Management API
Encoding API
HTML Sanitizer API
File and Directory Entries API
File System Access API
Frame Timing API
IndexedDB API
Long Tasks API
Navigation Timing API
Performance API
Performance Timeline
Resource Timing API
Payment Request API
Storage Access API
Storage API
Web Authentication API
Web Crypto API
Web Storage API
Web Workers API

Data management

Background Tasks API
Console API
Contact Picker API
Credential Management API
Encoding API
HTML Sanitizer API
File and Directory Entries API
File System Access API
Frame Timing API
IndexedDB API
Long Tasks API
Navigation Timing API
Performance API
Performance Timeline
Resource Timing API
Payment Request API
Storage Access API
Storage API
Web Authentication API
Web Crypto API
Web Storage API
Web Workers API

Data management

Background Tasks API
Console API
Contact Picker API
Credential Management API
Encoding API
HTML Sanitizer API
File and Directory Entries API
File System Access API
Frame Timing API
IndexedDB API
Long Tasks API
Navigation Timing API
Performance API
Performance Timeline
Resource Timing API
Payment Request API
Storage Access API
Storage API
Web Authentication API
Web Crypto API
Web Storage API
Web Workers API

Takeaways

WebAssembly