SlideShare a Scribd company logo
APIsfor modern web apps
chris mills, mozillA
Get the slides!
•Don’t worry about notes
•You can get the slides from slideshare.net/
chrisdavidmills
•Sit back and relax
•Or fidget if you get bored…
•Ask questions at @chrisdavidmills or
cmills@mozilla.com
who am i?
•I’m Chris
•Mozilla, MDN writer
•Twiddling around with JS/CSS/HTML
•APIs
•Educational material
•Accessibility whiner
•Heavy metal drummer
APIslike, what are we talking about?
•I really mean browser JavaScript APIs
•Exposing complex functionality to JS
•Making the Web more powerful and useful
api, why oh why?
•For a time, we only really had a few APIs
•We had DOM stuff, and XHR
•(And a bunch of horrid non-standard stuff)
•But the scene exploded
•WHATWG, Web Apps WG, and others
api, why oh why?
•Earlier APIs added interesting new features
•E.g. Geolocation, Canvas
•But this still wasn’t enough
api, why oh why?
•We want to remain competitive with native
•Get everything working together more
cohesively
•Deal with multimedia effectively in the
browser
•Improve performance, for games, etc.
•Improve internationalization
api, why oh why?
catching native
progressive apps
•Native platforms had better functionality
•We want to catch up, and make it webby
web versus native
•The Web is a good thing
•Progressive enhancement
•No app stores
•You can’t cache seamlessly on native, or
render text easily/fluidly
we love web
•Installable/discoverable
•Offline
•Re-engageable
•Linkable
•Responsive
•Safe
•and of course, Progressive
progressive apps
Installablei got you under my skin
installing apps
•The web can do this too!
•Without app stores
•Web App Manifest defines app features
•Including icons, background, splash screen,
theme colors…
•App files cached on device too (see later)
installing apps
Manifest example
{
"name": "My sample app",
"short_name": "MY app",
"start_url": "./?
utm_source=web_app_manifest",
"display": "standalone",
"icons": [{
"src": "images/touch/homescreen48.png",
"sizes": "48x48",
"type": "image/png"
}, {
"src": "images/touch/homescreen72.png",
"sizes": "72x72",
"type": "image/png"
}, {
"src": "images/touch/homescreen96.png",
•Also helps with discoverability
•The web largely does this anyway
•Standardised metadata mechanism is nice
•Better represent apps on search results,
social media, (app stores?!) etc.
discoverability
we already do it
<meta property="og:description"
content="Add-ons …">
<meta name="description" content="Add-ons
add …">
<meta name="twitter:description"
content="Add-ons add …”>
offlinestill a problem?
No connection = no experience
•Offline data storage
•Offline asset storage
•Reacting to network changes
offline is hard
•Not so bad
•We have storage mechanisms (e.g.
IndexedDB, Web Storage, WebSQL)
•Something available in most browsers
•Plus polyfills (e.g. LocalForage)
offline data
•More of a pain
•We had AppCache…
offline assets
CACHE MANIFEST
# v1
CACHE:
css/app.css
index.html
js/main.js
js/lib/require.js
this had promise
•It’s actually fairly useless
•Too much voodoo…
•Assumed a specific set of behaviours
but….
Hello service workers!
•Proxy servers that sit between app and
network
•Intercepting network requests and
customising responses
•Does similar things to AppCache (plus a lot
more…much harder to use)
•Granular control over actions
sw are cool
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw-test/sw.js', {
scope: '/*'
}).then(function(sw) {
// registration worked
console.log('Registration succeeded.');
}).catch(function() {
// registration failed
console.log('Registration failed.');
});
}
registration
this.addEventListener('install', function(event) {
event.waitUntil(
caches.open('v1').then(function(cache) {
return cache.addAll([
'/sw-test/',
'/sw-test/index.html',
'/sw-test/style.css',
'/sw-test/app.js',
'/sw-test/image-list.js',
'/sw-test/star-wars-logo.jpg',
'/sw-test/gallery/bountyHunters.jpg',
'/sw-test/gallery/myLittleVader.jpg',
'/sw-test/gallery/snowTroopers.jpg'
]);
})
);
});
installation
this.addEventListener('fetch', function(event) {
var response;
event.respondWith(caches.match(event.request)
.catch(function() {
return fetch(event.request);
}).then(function(r) {
response = r;
caches.open('v1').then(function(cache) {
cache.put(event.request, response);
});
return response.clone();
}).catch(function() {
return caches.match(‘/sw-test/gallery/
myLittleVader.jpg');
}));
});
custom responses
•The app container should be lightweight
HTML/CSS/JS
•Load fast, be cached, load on repeat visits
•The content should then update dynamically
•See Instant Loading Web Apps with An
Application Shell Architecture
App shell
reengagementhey, come back!!!
•You have new followers
•Your friend posted a new photo
•Your pokemon wants another fight
•You have mail
•The government wants to read your mail
•etc.
hello users
•Native was always good at reengagement
•Now web can do it too, even when the app
isn’t being used
•Push API
•Notifications API
•Channel Messaging API
•etc.
People love it
•Needs an active SW controlling the app
•Subscribe to push messages
•Send special endpoint to your server (URL)
•Send messages to this endpoint
•Push server sends them to the SW
needs a sw
navigator.serviceWorker.ready.then(function(reg) {
reg.pushManager.getSubscription()

.then(function(subscription) {
// Enable any UI for subscribing to push messages.
var endpoint = subscription.endpoint;
updateStatus(endpoint,'init');
}).catch(function(err) {
console.log('Error during getSubscription()', err);
});
});

push
self.addEventListener('push', function(event) {
var obj = event.data.json(); 

event.waitUntil(
self.registration.showNotification(title, {
body: obj.name + ‘ has subscribed.’,
icon: icon,
tag: tag
})
);

});

notifications
var channel = new MessageChannel();
channel.port1.onmessage = function(e) {
alert(e.data);
}
mySW = reg.active;
mySW.postMessage('hello', [channel.port2]);

channel msg
var port;
self.onmessage = function(e) {
port = e.ports[0];
}



port.postMessage(obj);

continuityspecs working together
•Creating extra work, repetition, and
confusion
•E.g. CSS and SVG functionality overlap
•Led to them forming the FXTF
•More care taken these days
•Extensible web manifesto — modular and
explainable
silos aren’t cool
•Fetch is a good example
•Similar to what XHR does
•Abstracts the whole request/response model
as JS objects
•So it can be used with other APIs like
Service Workers
fetch / sw
•Other specs also work well with/are based
on SW:
•Notifications API
•Push API
•Channel Messaging
•They all contain partial additions for SW
sw add-ons
mediaweb audio visuals
•Media was broken for years on the Web
•Audio/video delivery needed Flash for so
long
•The <video> tag took long enough
fix media
•WebRTC/gUM for accessing streams
•Should solve many use cases, from simple
image capture, video streaming, up to multi-
person video conferencing
•What about recording?
•Media Recorder API
media capture
var constraints = { audio: true, video: true };
var p =
navigator.mediaDevices.getUserMedia(constraints);
p.then(function(stream) {
// do something with the stream in here
});
p.catch(function(err) { console.log(err.name); });
getusermedia
var mediaRecorder = new MediaRecorder(stream);
record.onclick = function() {
mediaRecorder.start();
}
stop.onclick = function() {
mediaRecorder.stop();
}
mediaRecorder.ondataavailable = function(e) {
var video = document.createElement('video');
video.setAttribute('controls', '');
var videoURL = window.URL.createObjectURL(e.data);
video.src = videoURL;
}
media recorder
•Media Source Extensions
•Encrypted Media Extensions
•DRM on the Web?!?
•A necessary evil, WRT services like
Netflix..?
•Netflix involved in both the above specs
streaming/drm
•Web Audio API
•Precise audio control
•Add effects
•Split and merge audio channels
•Spatialization
•Audio visualizations
audio processing
Performancefaster and faster…
•General performance much improved
•Web Workers
•Emscripten/asm.js (Web Assembly coming
soon-ish)
•WebGL
•SIMD
performance
APIs for modern web apps
I18ninternationalization
•The Web is international
•But adapting sites for an intl. audience is a
pain
•E.g. Dealing with time/date formats
•And BIDI websites
•But we are working on this too
i18n
var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
console.log(new Intl.DateTimeFormat().format(date));

console.log(new Intl.DateTimeFormat('en-
US').format(date));



// DateTimeFormat without arguments returns the

// correct value for the language/timezone.
JavaScript i18n api
•The JS Internationalization API provides
features for formatting dates/times for
different languages, etc.
#content {
padding-left: 12px:
margin-right: 20px;
}

html[dir="rtl"] #content {
padding-left: 0;
padding-right: 12px;
margin-right: 0;
margin-left: 20px;
}
CSS BIDI features
•BIDI websites are simpler to layout with CSS
BIDI features
#content {
padding-inline-start: 12px:
margin-inline-end: 20px;
}
CSS BIDI features
FinitoThanks for listening!
@chrisdavidmills, cmills@mozilla.com slideshare.net/chrisdavidmills
•Main image: Bokeh Dandelion, by Nicolas
Raymond
credits

More Related Content

PDF
APIs, now and in the future
PDF
Web versus Native: round 1!
PDF
Empowering the "mobile web"
PDF
High Performance JavaScript - WebDirections USA 2010
PDF
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
PDF
High Performance JavaScript - jQuery Conference SF Bay Area 2010
PDF
Instant and offline apps with Service Worker
PPTX
Enough with the JavaScript already!
APIs, now and in the future
Web versus Native: round 1!
Empowering the "mobile web"
High Performance JavaScript - WebDirections USA 2010
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
High Performance JavaScript - jQuery Conference SF Bay Area 2010
Instant and offline apps with Service Worker
Enough with the JavaScript already!

What's hot (19)

PPTX
HTML5 Web Workers-unleashed
PDF
Performance on the Yahoo! Homepage
KEY
An Introduction to webOS
PDF
High Performance JavaScript (YUIConf 2010)
PDF
Keeping the frontend under control with Symfony and Webpack
PPTX
Disrupting the application eco system with progressive web applications
PDF
Chrome enchanted 2015
PDF
High Performance JavaScript (Amazon DevCon 2011)
PDF
PWA 與 Service Worker
PDF
Learning from the Best jQuery Plugins
PDF
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
KEY
Getting Started with HTML 5 Web workers
PDF
Web workers
PDF
JavaScript Web Workers
PPTX
Don't Over-React - just use Vue!
PPTX
Node JS Express : Steps to Create Restful Web App
KEY
#NewMeetup Performance
PDF
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
PDF
Service Worker - Reliability bits
HTML5 Web Workers-unleashed
Performance on the Yahoo! Homepage
An Introduction to webOS
High Performance JavaScript (YUIConf 2010)
Keeping the frontend under control with Symfony and Webpack
Disrupting the application eco system with progressive web applications
Chrome enchanted 2015
High Performance JavaScript (Amazon DevCon 2011)
PWA 與 Service Worker
Learning from the Best jQuery Plugins
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Getting Started with HTML 5 Web workers
Web workers
JavaScript Web Workers
Don't Over-React - just use Vue!
Node JS Express : Steps to Create Restful Web App
#NewMeetup Performance
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
Service Worker - Reliability bits
Ad

Viewers also liked (20)

PDF
Feedback handling, community wrangling, panhandlin’
DOC
Safaa Ahmed Social media - Final (1)
PDF
김구라의직장생활조언
PDF
Positionspapier: Umstrukturierung des deutschen Sekundärregelleistungsmarktes...
PDF
Curriculum vita
DOCX
Johan mateo ortiz 11
PPTX
ÁREA DE TECNOLOGÍA E INFORMÁTICA EN EL INSTITUTO
DOC
Agenda Arquidiocesana N°299
PDF
Cisco IP Routing 1.0 Expert
PPTX
Problemas del aprendizaje
PDF
NetVLAD: CNN architecture for weakly supervised place recognition
PPTX
Civic Engagement 101
PDF
A rainbow primary care for india
PDF
Rolling Arrays - The Trusted HR Transformation Partner
PDF
TTMRK-CT
PDF
"HP vision Governing the use of open source" by Martin Michlmayr @ eLiberatic...
RTF
PPT
Librasvideonew
PPTX
Apresentações: o que os melhores apresentadores sabem, fazem e falam
Feedback handling, community wrangling, panhandlin’
Safaa Ahmed Social media - Final (1)
김구라의직장생활조언
Positionspapier: Umstrukturierung des deutschen Sekundärregelleistungsmarktes...
Curriculum vita
Johan mateo ortiz 11
ÁREA DE TECNOLOGÍA E INFORMÁTICA EN EL INSTITUTO
Agenda Arquidiocesana N°299
Cisco IP Routing 1.0 Expert
Problemas del aprendizaje
NetVLAD: CNN architecture for weakly supervised place recognition
Civic Engagement 101
A rainbow primary care for india
Rolling Arrays - The Trusted HR Transformation Partner
TTMRK-CT
"HP vision Governing the use of open source" by Martin Michlmayr @ eLiberatic...
Librasvideonew
Apresentações: o que os melhores apresentadores sabem, fazem e falam
Ad

Similar to APIs for modern web apps (20)

PDF
Why Javascript matters
PDF
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
PPTX
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
KEY
Intro To webOS
PPTX
Mobile native-hacks
PDF
Empowering the Mobile Web - Mills
PDF
Empowering the “Mobile Web” with Chris Mills
PPTX
Intro to node and mongodb 1
PDF
Riding the Edge with Ember.js
KEY
Android lessons you won't learn in school
PDF
Utilizing HTML5 APIs
KEY
Google App Engine Java, Groovy and Gaelyk
PDF
Android
PDF
Mobile Vue.js – From PWA to Native
PDF
App engine devfest_mexico_10
PDF
How to overengineer a meme generator
PPTX
HTML5 for Rich User Experience
PPTX
Service workers your applications never felt so good
PDF
Building APIs in an easy way using API Platform
PPTX
AWS re:Invent 2016: Content and Data Platforms at Vevo: Rebuilding and Scalin...
Why Javascript matters
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
Intro To webOS
Mobile native-hacks
Empowering the Mobile Web - Mills
Empowering the “Mobile Web” with Chris Mills
Intro to node and mongodb 1
Riding the Edge with Ember.js
Android lessons you won't learn in school
Utilizing HTML5 APIs
Google App Engine Java, Groovy and Gaelyk
Android
Mobile Vue.js – From PWA to Native
App engine devfest_mexico_10
How to overengineer a meme generator
HTML5 for Rich User Experience
Service workers your applications never felt so good
Building APIs in an easy way using API Platform
AWS re:Invent 2016: Content and Data Platforms at Vevo: Rebuilding and Scalin...

More from Chris Mills (20)

PDF
More efficient, usable web
PDF
Guerrilla education
PDF
BrazilJS MDN
PDF
Documentation and publishing
PDF
MDN is easy!
PDF
Getting rid of images with CSS
PDF
Future layouts
PDF
Laying out the future
PDF
Accessibility doesn't exist
PDF
Responsive web design standards?
PDF
Adapt! Media queries and viewport
PDF
Adapt and respond: keeping responsive into the future
KEY
Angels versus demons: balancing shiny and inclusive
PDF
HTML5 and CSS3: does now really mean now?
PDF
The W3C and the web design ecosystem
PDF
HTML5 Pearson preso
PDF
Brave new world of HTML5
KEY
Inclusive design: real accessibility for everyone
KEY
The web standards gentleman: a matter of (evolving) standards)
KEY
Optimizing content for the "mobile web"
More efficient, usable web
Guerrilla education
BrazilJS MDN
Documentation and publishing
MDN is easy!
Getting rid of images with CSS
Future layouts
Laying out the future
Accessibility doesn't exist
Responsive web design standards?
Adapt! Media queries and viewport
Adapt and respond: keeping responsive into the future
Angels versus demons: balancing shiny and inclusive
HTML5 and CSS3: does now really mean now?
The W3C and the web design ecosystem
HTML5 Pearson preso
Brave new world of HTML5
Inclusive design: real accessibility for everyone
The web standards gentleman: a matter of (evolving) standards)
Optimizing content for the "mobile web"

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
KodekX | Application Modernization Development
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PDF
Encapsulation theory and applications.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
The AUB Centre for AI in Media Proposal.docx
sap open course for s4hana steps from ECC to s4
MIND Revenue Release Quarter 2 2025 Press Release
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Dropbox Q2 2025 Financial Results & Investor Presentation
20250228 LYD VKU AI Blended-Learning.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KodekX | Application Modernization Development
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
Encapsulation theory and applications.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding

APIs for modern web apps

  • 1. APIsfor modern web apps chris mills, mozillA
  • 2. Get the slides! •Don’t worry about notes •You can get the slides from slideshare.net/ chrisdavidmills •Sit back and relax •Or fidget if you get bored… •Ask questions at @chrisdavidmills or cmills@mozilla.com
  • 3. who am i? •I’m Chris •Mozilla, MDN writer •Twiddling around with JS/CSS/HTML •APIs •Educational material •Accessibility whiner •Heavy metal drummer
  • 4. APIslike, what are we talking about?
  • 5. •I really mean browser JavaScript APIs •Exposing complex functionality to JS •Making the Web more powerful and useful api, why oh why?
  • 6. •For a time, we only really had a few APIs •We had DOM stuff, and XHR •(And a bunch of horrid non-standard stuff) •But the scene exploded •WHATWG, Web Apps WG, and others api, why oh why?
  • 7. •Earlier APIs added interesting new features •E.g. Geolocation, Canvas •But this still wasn’t enough api, why oh why?
  • 8. •We want to remain competitive with native •Get everything working together more cohesively •Deal with multimedia effectively in the browser •Improve performance, for games, etc. •Improve internationalization api, why oh why?
  • 10. •Native platforms had better functionality •We want to catch up, and make it webby web versus native
  • 11. •The Web is a good thing •Progressive enhancement •No app stores •You can’t cache seamlessly on native, or render text easily/fluidly we love web
  • 13. Installablei got you under my skin
  • 15. •The web can do this too! •Without app stores •Web App Manifest defines app features •Including icons, background, splash screen, theme colors… •App files cached on device too (see later) installing apps
  • 16. Manifest example { "name": "My sample app", "short_name": "MY app", "start_url": "./? utm_source=web_app_manifest", "display": "standalone", "icons": [{ "src": "images/touch/homescreen48.png", "sizes": "48x48", "type": "image/png" }, { "src": "images/touch/homescreen72.png", "sizes": "72x72", "type": "image/png" }, { "src": "images/touch/homescreen96.png",
  • 17. •Also helps with discoverability •The web largely does this anyway •Standardised metadata mechanism is nice •Better represent apps on search results, social media, (app stores?!) etc. discoverability
  • 18. we already do it <meta property="og:description" content="Add-ons …"> <meta name="description" content="Add-ons add …"> <meta name="twitter:description" content="Add-ons add …”>
  • 20. No connection = no experience
  • 21. •Offline data storage •Offline asset storage •Reacting to network changes offline is hard
  • 22. •Not so bad •We have storage mechanisms (e.g. IndexedDB, Web Storage, WebSQL) •Something available in most browsers •Plus polyfills (e.g. LocalForage) offline data
  • 23. •More of a pain •We had AppCache… offline assets
  • 25. •It’s actually fairly useless •Too much voodoo… •Assumed a specific set of behaviours but….
  • 27. •Proxy servers that sit between app and network •Intercepting network requests and customising responses •Does similar things to AppCache (plus a lot more…much harder to use) •Granular control over actions sw are cool
  • 28. if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw-test/sw.js', { scope: '/*' }).then(function(sw) { // registration worked console.log('Registration succeeded.'); }).catch(function() { // registration failed console.log('Registration failed.'); }); } registration
  • 29. this.addEventListener('install', function(event) { event.waitUntil( caches.open('v1').then(function(cache) { return cache.addAll([ '/sw-test/', '/sw-test/index.html', '/sw-test/style.css', '/sw-test/app.js', '/sw-test/image-list.js', '/sw-test/star-wars-logo.jpg', '/sw-test/gallery/bountyHunters.jpg', '/sw-test/gallery/myLittleVader.jpg', '/sw-test/gallery/snowTroopers.jpg' ]); }) ); }); installation
  • 30. this.addEventListener('fetch', function(event) { var response; event.respondWith(caches.match(event.request) .catch(function() { return fetch(event.request); }).then(function(r) { response = r; caches.open('v1').then(function(cache) { cache.put(event.request, response); }); return response.clone(); }).catch(function() { return caches.match(‘/sw-test/gallery/ myLittleVader.jpg'); })); }); custom responses
  • 31. •The app container should be lightweight HTML/CSS/JS •Load fast, be cached, load on repeat visits •The content should then update dynamically •See Instant Loading Web Apps with An Application Shell Architecture App shell
  • 33. •You have new followers •Your friend posted a new photo •Your pokemon wants another fight •You have mail •The government wants to read your mail •etc. hello users
  • 34. •Native was always good at reengagement •Now web can do it too, even when the app isn’t being used •Push API •Notifications API •Channel Messaging API •etc. People love it
  • 35. •Needs an active SW controlling the app •Subscribe to push messages •Send special endpoint to your server (URL) •Send messages to this endpoint •Push server sends them to the SW needs a sw
  • 36. navigator.serviceWorker.ready.then(function(reg) { reg.pushManager.getSubscription()
 .then(function(subscription) { // Enable any UI for subscribing to push messages. var endpoint = subscription.endpoint; updateStatus(endpoint,'init'); }).catch(function(err) { console.log('Error during getSubscription()', err); }); });
 push
  • 37. self.addEventListener('push', function(event) { var obj = event.data.json(); 
 event.waitUntil( self.registration.showNotification(title, { body: obj.name + ‘ has subscribed.’, icon: icon, tag: tag }) );
 });
 notifications
  • 38. var channel = new MessageChannel(); channel.port1.onmessage = function(e) { alert(e.data); } mySW = reg.active; mySW.postMessage('hello', [channel.port2]);
 channel msg var port; self.onmessage = function(e) { port = e.ports[0]; }
 
 port.postMessage(obj);

  • 40. •Creating extra work, repetition, and confusion •E.g. CSS and SVG functionality overlap •Led to them forming the FXTF •More care taken these days •Extensible web manifesto — modular and explainable silos aren’t cool
  • 41. •Fetch is a good example •Similar to what XHR does •Abstracts the whole request/response model as JS objects •So it can be used with other APIs like Service Workers fetch / sw
  • 42. •Other specs also work well with/are based on SW: •Notifications API •Push API •Channel Messaging •They all contain partial additions for SW sw add-ons
  • 44. •Media was broken for years on the Web •Audio/video delivery needed Flash for so long •The <video> tag took long enough fix media
  • 45. •WebRTC/gUM for accessing streams •Should solve many use cases, from simple image capture, video streaming, up to multi- person video conferencing •What about recording? •Media Recorder API media capture
  • 46. var constraints = { audio: true, video: true }; var p = navigator.mediaDevices.getUserMedia(constraints); p.then(function(stream) { // do something with the stream in here }); p.catch(function(err) { console.log(err.name); }); getusermedia
  • 47. var mediaRecorder = new MediaRecorder(stream); record.onclick = function() { mediaRecorder.start(); } stop.onclick = function() { mediaRecorder.stop(); } mediaRecorder.ondataavailable = function(e) { var video = document.createElement('video'); video.setAttribute('controls', ''); var videoURL = window.URL.createObjectURL(e.data); video.src = videoURL; } media recorder
  • 48. •Media Source Extensions •Encrypted Media Extensions •DRM on the Web?!? •A necessary evil, WRT services like Netflix..? •Netflix involved in both the above specs streaming/drm
  • 49. •Web Audio API •Precise audio control •Add effects •Split and merge audio channels •Spatialization •Audio visualizations audio processing
  • 51. •General performance much improved •Web Workers •Emscripten/asm.js (Web Assembly coming soon-ish) •WebGL •SIMD performance
  • 54. •The Web is international •But adapting sites for an intl. audience is a pain •E.g. Dealing with time/date formats •And BIDI websites •But we are working on this too i18n
  • 55. var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); console.log(new Intl.DateTimeFormat().format(date));
 console.log(new Intl.DateTimeFormat('en- US').format(date));
 
 // DateTimeFormat without arguments returns the
 // correct value for the language/timezone. JavaScript i18n api •The JS Internationalization API provides features for formatting dates/times for different languages, etc.
  • 56. #content { padding-left: 12px: margin-right: 20px; }
 html[dir="rtl"] #content { padding-left: 0; padding-right: 12px; margin-right: 0; margin-left: 20px; } CSS BIDI features •BIDI websites are simpler to layout with CSS BIDI features
  • 58. FinitoThanks for listening! @chrisdavidmills, cmills@mozilla.com slideshare.net/chrisdavidmills
  • 59. •Main image: Bokeh Dandelion, by Nicolas Raymond credits