The current state of web

The Current state of web
@ritz078
The web is getting better.
IntersectionObserver
The Intersection Observer API provides a way to asynchronously
observe changes in the intersection of a target element with an
ancestor element or with a top-level document's viewport.
var io = new IntersectionObserver(
entries !=> {
console.log(entries);
}
);
!// Start observing an element
io.observe(element);
!// Stop observing an element
!// io.unobserve(element);
!// Disable IntersectionObserver
!// io.disconnect();
https://codepen.io/ritz078/pen/GdxbKJ
Demo
Polyfill
https://github.com/w3c/IntersectionObserver/tree/master/polyfill
ResizeObserver
ResizeObserver allows you to be notified when an element’s
content rectangle has changed its size, and react
accordingly.
API
var ro = new ResizeObserver( entries !=> {
for (let entry of entries) {
const cr = entry.contentRect;
console.log('Element:', entry.target);
console.log(`Element size: ${cr.width}px x ${cr.height}px`);
console.log(`Element padding: ${cr.top}px ; ${cr.left}px`);
}
});
!// Observe one or multiple elements
ro.observe(someElement);
•Observes the content box.
•Reports dimension and
padding.
•Polyfills aren’t performant as
they rely on polling.
Variable Fonts
•Single file for all variations of a font.
•5 pre-defined axes that can be changed.
•Custom variable axes can be defined by the designer.
•Animation is possible.
•Use fallback font by changing format.
@font-face {
font-family: "source sans";
src: url(SourceSansVariable.woff2) format("woff2-variations"),
url(SourceSans.woff2) format("woff2"); !/* for older browsers !*/
font-weight: normal;
font-style: normal;
}
https://variable-font-experiments.glitch.me/
Abortable Fetch
AbortController and AbortSignal Generic API
const controller = new AbortController();
const signal = controller.signal;
controller.abort();
signal.addEventListener('abort', () !=> {
!// Logs true:
console.log(signal.aborted);
});
const controller = new AbortController();
const signal = controller.signal;
setTimeout(() !=> controller.abort(), 5000);
fetch(url, { signal })
.then(response !=> response.text())
.then(console.log)
.catch(err !=> {
if (err.name !!=== "AbortError") {
console.log("Fetch aborted");
} else {
console.error("Uh oh, an error!", err);
}
});
Timeout fetch using AbortSignal
A single signal can be used to abort many fetches at once
Async ClipBoard API
document.execCommand ?
• It’s synchronous.
• Can only read and write to DOM.
• Permissions model are lossely defined and vary
across browsers
navigator.clipboard.writeText('Text to be copied')
.then(() !=> {
console.log('Text copied to clipboard');
})
.catch(err !=> {
!// This can happen if the user denies clipboard permissions
console.error('Could not copy text: ', err);
});
API
https://jsfiddle.net/r2jurqq7/
• It’s asynchronous.
• Can read and write from the clipboard.
• Need permission to read from clipboard.
CSS Typed Object Model
Old CSSOM
!// Element styles.
el.style.opacity = 0.3;
typeof el.style.opacity !!=== 'string' !// Ugh. A string!?
!// Stylesheet rules.
document.styleSheets[0].cssRules[0].style.opacity = 0.3;
New CSS Typed OM
!// Element styles.
el.attributeStyleMap.set('opacity', 0.3);
typeof el.attributeStyleMap.get('opacity').value !!=== 'number'
!// Yay, a number!
!// Stylesheet rules.
const stylesheet = document.styleSheets[0];
stylesheet.cssRules[0].styleMap.set('background', 'blue');
el.attributeStyleMap is a ES6 Map
!// All 3 of these are equivalent:
el.attributeStyleMap.set('opacity', 0.3);
el.attributeStyleMap.set('opacity', '0.3');
el.attributeStyleMap.set('opacity', CSS.number(0.3));
!// el.attributeStyleMap.get('opacity').value !!=== 0.3
!// StylePropertyMaps are iterable.
for (const [prop, val] of el.attributeStyleMap) {
console.log(prop, val.value);
}
!// → opacity, 0.3
el.attributeStyleMap.has('opacity') !// true
el.attributeStyleMap.delete('opacity') !// remove opacity.
el.attributeStyleMap.clear(); !// remove all styles.
Web Workers
I know, it’s old
• run scripts in background threads.
• No access to DOM.
• Communication via postMessage API
!// main.js
const myWorker = new Worker('worker.js');
first.onchange = function() {
myWorker.postMessage([first.value,second.value]);
console.log('Message posted to worker');
}
!// worker.js
onmessage = function(e) {
console.log('Message received from main script');
var workerResult = 'Result: ' + (e.data[0] * e.data[1]);
console.log('Posting message back to main script');
postMessage(workerResult);
}
https://transform.now.sh
• Prettier is in worker.
• Transformations that don’t
depend on the DOM are in
worker.
• Used the package greenlet
to move async functions to
the separate thread.
Immersive Web
The current state of web
if (navigator.xr) {
navigator.xr.requestDevice()
.then(xrDevice !=> {
!// Advertise the AR/VR functionality to get a user gesture.
})
.catch(err !=> {
if (err.name !!=== 'NotFoundError') {
!// No XRDevices available.
console.error('No XR devices available:', err);
} else {
!// An error occurred while requesting an XRDevice.
console.error('Requesting XR device failed:', err);
}
})
} else{
console.log("This browser does not support the WebXR API.");
}
WebXR Device API
WebXR Device API does not provide image rendering features.
Drawing is done using WebGL APIs
Web MIDI API
MIDI lets you connect controllers, synthesizers and
more to your computer.
if (navigator.requestMIDIAccess) {
console.log('This browser supports WebMIDI!');
} else {
console.log('WebMIDI is not supported in this browser.');
}
navigator.requestMIDIAccess()
.then(onMIDISuccess, onMIDIFailure);
function onMIDISuccess(midiAccess) {
console.log(midiAccess);
var inputs = midiAccess.inputs;
var outputs = midiAccess.outputs;
}
function onMIDIFailure() {
console.log('Could not access your MIDI devices.');
}
API
function onMIDISuccess(midiAccess) {
for (var input of midiAccess.inputs.values())
input.onmidimessage = getMIDIMessage;
}
}
function getMIDIMessage(midiMessage) {
console.log(midiMessage);
}
Listening to input messages
Polyfill: https://github.com/cwilso/WebMIDIAPIShim
There’s more
•CSS Paint API
•Houdini
•CSS Grids
•Network Quality
References
https://developers.google.com/web/
Thank You
@ritz078
1 of 43

Recommended

React Native: The Development Flow by
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development FlowRitesh Kumar
645 views46 slides
Intro to JavaScript by
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
2K views49 slides
Philip Shurpik "Architecting React Native app" by
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Fwdays
2.1K views57 slides
Reactive Streams and RxJava2 by
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2Yakov Fain
3.9K views55 slides
React Development with the MERN Stack by
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
2.2K views81 slides
Asynchronous Task Queues with Celery by
Asynchronous Task Queues with CeleryAsynchronous Task Queues with Celery
Asynchronous Task Queues with CeleryKishor Kumar
633 views14 slides

More Related Content

What's hot

Zenly - Reverse geocoding by
Zenly - Reverse geocodingZenly - Reverse geocoding
Zenly - Reverse geocodingCocoaHeads France
5.3K views20 slides
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (... by
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...Badoo
1.2K views35 slides
Celery introduction by
Celery introductionCelery introduction
Celery introductionIonel Mărieș Cristian
514 views13 slides
Ember testing internals with ember cli by
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cliCory Forsyth
13.7K views55 slides
JavaScript Web Workers by
JavaScript Web WorkersJavaScript Web Workers
JavaScript Web WorkersTobias Pfeiffer
4.1K views50 slides
Testing Ember Apps: Managing Dependency by
Testing Ember Apps: Managing DependencyTesting Ember Apps: Managing Dependency
Testing Ember Apps: Managing DependencyMatthew Beale
10.7K views69 slides

What's hot(20)

iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (... by Badoo
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...
Badoo1.2K views
Ember testing internals with ember cli by Cory Forsyth
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cli
Cory Forsyth13.7K views
Testing Ember Apps: Managing Dependency by Matthew Beale
Testing Ember Apps: Managing DependencyTesting Ember Apps: Managing Dependency
Testing Ember Apps: Managing Dependency
Matthew Beale10.7K views
Setting Apple's UI Automation Free with Appium by mobiletestsummit
Setting Apple's UI Automation Free with AppiumSetting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with Appium
mobiletestsummit7.9K views
Test like a pro with Ember.js by Mike North
Test like a pro with Ember.jsTest like a pro with Ember.js
Test like a pro with Ember.js
Mike North8K views
Type script for_java_dev_jul_2020 by Yakov Fain
Type script for_java_dev_jul_2020Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020
Yakov Fain289 views
Setting UIAutomation free with Appium by Dan Cuellar
Setting UIAutomation free with AppiumSetting UIAutomation free with Appium
Setting UIAutomation free with Appium
Dan Cuellar643 views
Testing frontends with nightwatch & saucelabs by Tudor Barbu
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabs
Tudor Barbu1.4K views
Jquery- One slide completing all JQuery by Knoldus Inc.
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
Knoldus Inc.3.1K views
UI Testing Best Practices - An Expected Journey by Oren Farhi
UI Testing Best Practices - An Expected JourneyUI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected Journey
Oren Farhi5.1K views
Introduction to Protractor by Jie-Wei Wu
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
Jie-Wei Wu4.8K views

Similar to The current state of web

JavaScript Basics by
JavaScript BasicsJavaScript Basics
JavaScript BasicsMats Bryntse
1.6K views18 slides
Mobile webapplication development by
Mobile webapplication developmentMobile webapplication development
Mobile webapplication developmentGanesh Gembali
818 views29 slides
The Evolution of Async-Programming on .NET Platform (.Net China, C#) by
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)jeffz
2.1K views61 slides
An opinionated intro to Node.js - devrupt hospitality hackathon by
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonLuciano Mammino
55 views40 slides
Time for intersection observer by
Time for intersection observerTime for intersection observer
Time for intersection observerJonas Ohlsson Aden
1.4K views45 slides
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra by
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra  SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra Sencha
420 views93 slides

Similar to The current state of web(20)

JavaScript Basics by Mats Bryntse
JavaScript BasicsJavaScript Basics
JavaScript Basics
Mats Bryntse1.6K views
Mobile webapplication development by Ganesh Gembali
Mobile webapplication developmentMobile webapplication development
Mobile webapplication development
Ganesh Gembali818 views
The Evolution of Async-Programming on .NET Platform (.Net China, C#) by jeffz
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
jeffz2.1K views
An opinionated intro to Node.js - devrupt hospitality hackathon by Luciano Mammino
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon
Luciano Mammino55 views
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra by Sencha
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra  SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
Sencha420 views
jQuery with javascript training by Technnovation Labs by Prasad Shende
jQuery with javascript training by Technnovation LabsjQuery with javascript training by Technnovation Labs
jQuery with javascript training by Technnovation Labs
Prasad Shende2.1K views
Introduction to Vert.x by Yiguang Hu
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
Yiguang Hu3.5K views
Writing robust Node.js applications by Tom Croucher
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher15.6K views
Intro to node.js - Ran Mizrahi (27/8/2014) by Ran Mizrahi
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
Ran Mizrahi1.1K views
Intro to node.js - Ran Mizrahi (28/8/14) by Ran Mizrahi
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi564 views
Workshop 4: NodeJS. Express Framework & MongoDB. by Visual Engineering
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
Visual Engineering1.6K views
Testable JavaScript: Application Architecture by Mark Trostler
Testable JavaScript:  Application ArchitectureTestable JavaScript:  Application Architecture
Testable JavaScript: Application Architecture
Mark Trostler2.9K views
Introduction to Performance APIs by Shogo Sensui
Introduction to Performance APIsIntroduction to Performance APIs
Introduction to Performance APIs
Shogo Sensui566 views
Servlet 3.1 Async I/O by Simone Bordet
Servlet 3.1 Async I/OServlet 3.1 Async I/O
Servlet 3.1 Async I/O
Simone Bordet16.2K views
Server Side JavaScript: Ajax.org O3. by ejpbruel
Server Side JavaScript: Ajax.org O3.Server Side JavaScript: Ajax.org O3.
Server Side JavaScript: Ajax.org O3.
ejpbruel339 views
Server Side JavaScript: Ajax.org O3 by Javeline B.V.
Server Side JavaScript: Ajax.org O3Server Side JavaScript: Ajax.org O3
Server Side JavaScript: Ajax.org O3
Javeline B.V.471 views
Module design pattern i.e. express js by Ahmed Assaf
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
Ahmed Assaf861 views

Recently uploaded

START Newsletter 3 by
START Newsletter 3START Newsletter 3
START Newsletter 3Start Project
6 views25 slides
Ansari: Practical experiences with an LLM-based Islamic Assistant by
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic AssistantM Waleed Kadous
5 views29 slides
802.11 Computer Networks by
802.11 Computer Networks802.11 Computer Networks
802.11 Computer NetworksTusharChoudhary72015
13 views33 slides
Generative AI Models & Their Applications by
Generative AI Models & Their ApplicationsGenerative AI Models & Their Applications
Generative AI Models & Their ApplicationsSN
10 views1 slide
Codes and Conventions.pptx by
Codes and Conventions.pptxCodes and Conventions.pptx
Codes and Conventions.pptxIsabellaGraceAnkers
13 views5 slides
LDPC_CODES.ppt by
LDPC_CODES.pptLDPC_CODES.ppt
LDPC_CODES.ppthsomashekar987
16 views44 slides

Recently uploaded(20)

Ansari: Practical experiences with an LLM-based Islamic Assistant by M Waleed Kadous
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic Assistant
M Waleed Kadous5 views
Generative AI Models & Their Applications by SN
Generative AI Models & Their ApplicationsGenerative AI Models & Their Applications
Generative AI Models & Their Applications
SN10 views
Design of machine elements-UNIT 3.pptx by gopinathcreddy
Design of machine elements-UNIT 3.pptxDesign of machine elements-UNIT 3.pptx
Design of machine elements-UNIT 3.pptx
gopinathcreddy33 views
SUMIT SQL PROJECT SUPERSTORE 1.pptx by Sumit Jadhav
SUMIT SQL PROJECT SUPERSTORE 1.pptxSUMIT SQL PROJECT SUPERSTORE 1.pptx
SUMIT SQL PROJECT SUPERSTORE 1.pptx
Sumit Jadhav 18 views
REACTJS.pdf by ArthyR3
REACTJS.pdfREACTJS.pdf
REACTJS.pdf
ArthyR334 views
_MAKRIADI-FOTEINI_diploma thesis.pptx by fotinimakriadi
_MAKRIADI-FOTEINI_diploma thesis.pptx_MAKRIADI-FOTEINI_diploma thesis.pptx
_MAKRIADI-FOTEINI_diploma thesis.pptx
fotinimakriadi8 views
Searching in Data Structure by raghavbirla63
Searching in Data StructureSearching in Data Structure
Searching in Data Structure
raghavbirla6314 views
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ... by AltinKaradagli
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...
AltinKaradagli15 views
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc... by csegroupvn
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
csegroupvn5 views
GDSC Mikroskil Members Onboarding 2023.pdf by gdscmikroskil
GDSC Mikroskil Members Onboarding 2023.pdfGDSC Mikroskil Members Onboarding 2023.pdf
GDSC Mikroskil Members Onboarding 2023.pdf
gdscmikroskil58 views
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx by lwang78
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
lwang78109 views
MongoDB.pdf by ArthyR3
MongoDB.pdfMongoDB.pdf
MongoDB.pdf
ArthyR345 views
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth by Innomantra
BCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for GrowthBCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for Growth
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth
Innomantra 6 views

The current state of web

  • 1. The Current state of web @ritz078
  • 2. The web is getting better.
  • 4. The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport.
  • 5. var io = new IntersectionObserver( entries !=> { console.log(entries); } ); !// Start observing an element io.observe(element); !// Stop observing an element !// io.unobserve(element); !// Disable IntersectionObserver !// io.disconnect();
  • 8. ResizeObserver allows you to be notified when an element’s content rectangle has changed its size, and react accordingly.
  • 9. API var ro = new ResizeObserver( entries !=> { for (let entry of entries) { const cr = entry.contentRect; console.log('Element:', entry.target); console.log(`Element size: ${cr.width}px x ${cr.height}px`); console.log(`Element padding: ${cr.top}px ; ${cr.left}px`); } }); !// Observe one or multiple elements ro.observe(someElement);
  • 10. •Observes the content box. •Reports dimension and padding. •Polyfills aren’t performant as they rely on polling.
  • 12. •Single file for all variations of a font. •5 pre-defined axes that can be changed. •Custom variable axes can be defined by the designer. •Animation is possible. •Use fallback font by changing format. @font-face { font-family: "source sans"; src: url(SourceSansVariable.woff2) format("woff2-variations"), url(SourceSans.woff2) format("woff2"); !/* for older browsers !*/ font-weight: normal; font-style: normal; }
  • 15. AbortController and AbortSignal Generic API const controller = new AbortController(); const signal = controller.signal; controller.abort(); signal.addEventListener('abort', () !=> { !// Logs true: console.log(signal.aborted); });
  • 16. const controller = new AbortController(); const signal = controller.signal; setTimeout(() !=> controller.abort(), 5000); fetch(url, { signal }) .then(response !=> response.text()) .then(console.log) .catch(err !=> { if (err.name !!=== "AbortError") { console.log("Fetch aborted"); } else { console.error("Uh oh, an error!", err); } }); Timeout fetch using AbortSignal
  • 17. A single signal can be used to abort many fetches at once
  • 19. document.execCommand ? • It’s synchronous. • Can only read and write to DOM. • Permissions model are lossely defined and vary across browsers
  • 20. navigator.clipboard.writeText('Text to be copied') .then(() !=> { console.log('Text copied to clipboard'); }) .catch(err !=> { !// This can happen if the user denies clipboard permissions console.error('Could not copy text: ', err); }); API https://jsfiddle.net/r2jurqq7/
  • 21. • It’s asynchronous. • Can read and write from the clipboard. • Need permission to read from clipboard.
  • 23. Old CSSOM !// Element styles. el.style.opacity = 0.3; typeof el.style.opacity !!=== 'string' !// Ugh. A string!? !// Stylesheet rules. document.styleSheets[0].cssRules[0].style.opacity = 0.3;
  • 24. New CSS Typed OM !// Element styles. el.attributeStyleMap.set('opacity', 0.3); typeof el.attributeStyleMap.get('opacity').value !!=== 'number' !// Yay, a number! !// Stylesheet rules. const stylesheet = document.styleSheets[0]; stylesheet.cssRules[0].styleMap.set('background', 'blue');
  • 26. !// All 3 of these are equivalent: el.attributeStyleMap.set('opacity', 0.3); el.attributeStyleMap.set('opacity', '0.3'); el.attributeStyleMap.set('opacity', CSS.number(0.3)); !// el.attributeStyleMap.get('opacity').value !!=== 0.3 !// StylePropertyMaps are iterable. for (const [prop, val] of el.attributeStyleMap) { console.log(prop, val.value); } !// → opacity, 0.3 el.attributeStyleMap.has('opacity') !// true el.attributeStyleMap.delete('opacity') !// remove opacity. el.attributeStyleMap.clear(); !// remove all styles.
  • 29. • run scripts in background threads. • No access to DOM. • Communication via postMessage API
  • 30. !// main.js const myWorker = new Worker('worker.js'); first.onchange = function() { myWorker.postMessage([first.value,second.value]); console.log('Message posted to worker'); } !// worker.js onmessage = function(e) { console.log('Message received from main script'); var workerResult = 'Result: ' + (e.data[0] * e.data[1]); console.log('Posting message back to main script'); postMessage(workerResult); }
  • 31. https://transform.now.sh • Prettier is in worker. • Transformations that don’t depend on the DOM are in worker. • Used the package greenlet to move async functions to the separate thread.
  • 34. if (navigator.xr) { navigator.xr.requestDevice() .then(xrDevice !=> { !// Advertise the AR/VR functionality to get a user gesture. }) .catch(err !=> { if (err.name !!=== 'NotFoundError') { !// No XRDevices available. console.error('No XR devices available:', err); } else { !// An error occurred while requesting an XRDevice. console.error('Requesting XR device failed:', err); } }) } else{ console.log("This browser does not support the WebXR API."); } WebXR Device API
  • 35. WebXR Device API does not provide image rendering features. Drawing is done using WebGL APIs
  • 37. MIDI lets you connect controllers, synthesizers and more to your computer.
  • 38. if (navigator.requestMIDIAccess) { console.log('This browser supports WebMIDI!'); } else { console.log('WebMIDI is not supported in this browser.'); }
  • 39. navigator.requestMIDIAccess() .then(onMIDISuccess, onMIDIFailure); function onMIDISuccess(midiAccess) { console.log(midiAccess); var inputs = midiAccess.inputs; var outputs = midiAccess.outputs; } function onMIDIFailure() { console.log('Could not access your MIDI devices.'); } API
  • 40. function onMIDISuccess(midiAccess) { for (var input of midiAccess.inputs.values()) input.onmidimessage = getMIDIMessage; } } function getMIDIMessage(midiMessage) { console.log(midiMessage); } Listening to input messages Polyfill: https://github.com/cwilso/WebMIDIAPIShim
  • 41. There’s more •CSS Paint API •Houdini •CSS Grids •Network Quality