SlideShare a Scribd company logo
1 of 31
Download to read offline
The Future of the 
Web 
...and the one polyfill that makes it all possible today
Browser Support 
WeakMap: Chrome, FF, IE11 
Object.observe: Chrome 36 
MutationObserver: all but IE10, Safari 6.1, Android 4.3 
Web Components: Chrome 36, FF 32, Android 4.4
WeakMap 
keys are objects 
values can be anything 
does not prevent garbage collection of keys
Use Cases 
Associate data with an element w/out augmenting the element 
Associate data with a read-only object 
More efficient information hiding
e.g. 
var map = new WeakMap(); 
var someEl = 
document.getElementById('someEl'); 
map.set(someEl, {foo: 'bar'}); 
if (map.has(document.getElementById('someEl') { 
map.get(someEl).foo; // bar 
}
Object.observe 
Receive callbacks when an object changes in any way 
Native impl for Angular's scope.$watch 
For Arrays: Array.observe 
Angular will delegate in 2.0
Angular 
scope.name = 'Ray'; 
scope.$watch('name', function(newV, oldV) { 
console.log('old name: ' + oldV); 
console.log('new name: ' + newV); 
});
Native 
scope.name = "Ray"; 
Object.observe(scope, function(change) { 
if (change.name === 'name') { 
console.log('old name: ' + 
change.oldValue); 
console.log('new value: ' + 
change.object[change.name]); 
} 
});
MutationObserver 
Receive callbacks when an element changes in any way 
Element descendendants can also be observed 
Replacement for inefficient Mutation Events
e.g. 
var callback = function(records) { 
var record = records[0]; // for demo simplicity only 
var added = record.addedNodes; 
if (added.length) { 
var newTags = 0; 
for (var i = 0; i < added.length; i++) { 
if (added[i].className.indexOf('tag') >= 0) { 
newTags++; 
} 
} 
if (newTags) { 
alert(newTags + " new tags added."); 
} 
} 
}; 
var observer = new MutationObserver(callback); 
observer.observe(tagsContainerEl, {childList: true});
Web Components 
Templates 
Custom Elements 
Shadow DOM
Templates 
Create re-usable content 
<template> is not rendered, must be 
"activated" 
Any elements can be children 
<template> 
<div>hi there</div> 
<div>you can't see me right now</div> 
<blink>luckily for you</blink> 
</template> 
Live example [jsbin]
HTML Imports 
Pull another HTML file into the current document 
Inject a packaged component (and all deps) w/ one line 
Re-use templates stored in a central location 
<link rel="import" href="/license.html">
Using an imported document 
// Grab the <link> that imports the licensing blurb 
var licensingLink = document.getElementById('licenseLink'); 
// Grab the relevant content from the imported doc 
var content = licensingLink.import.getElementById('license'); 
// Append the content to our doc 
document.body.appendChild(content); 
NOTE: Server must return proper CORS headers for cross-domain 
imports 
Complete example [jsbin]
Custom Elements 
<my-custom-element></my-custom-element> 
MUST contain a dash 
Take heed angular directive writers. 
Use ember? You're cool. 
Why? 
To avoid conflict w/ future standardized elements.
Creating Custom Elements 
Initially an :unresolved HTMLElement 
To "resolve", you must document.registerElement 
Two types: 
1. New* CE 
2. Type Extension CE 
* I just made up this name
Standard Custom Element 
<foo-bar> 
<!-- unresolved content --> 
</foo-bar> 
<script> 
</script> 
Live example [jsbin]
Type Extension Custom 
Element 
<video is="frame-grabber" src="somevideo.mp4"> 
</video> 
var frameGrabber = 
document.createElement('video', 'frame-grabber'); 
frameGrabber.prototype.grab = function() { 
// grab current frame & do something w/ it 
}
Shadow DOM 
Allows creation of self-contained, sandboxed web components 
A single Node can now be made up of 3 different subtrees: 
Light DOM 
Shadow DOM 
Composed DOM
Light DOM Tree 
Part of the "logical DOM" 
Content of the custom element provided by integrator 
<blink-is-back> 
Bring back the blink tag! 
</blink-is-back> 
Displayed pre-shadow-root render
Shadow DOM Tree 
Part of the "logical DOM" 
Internal to the custom element, not a child 
Not directly accessible via the light DOM 
1. Include element on page 
2. Register (if CE) 
3. myElement.createShadowRoot(); 
4. Append content to shadow root 
5. Live example [jsbin]
Composed DOM Tree 
Content that is actually rendered 
Pieces of the light and shadow DOM combined 
Composed DOM from the <blink-is-back> CE: 
<blink-is-back> 
<div style="text-decoration: line-through;"> 
Bring back the blink element! 
</div> 
<div>But seriously, don't make text blink.</div> 
</blink-is-back>
Polymer 
Shim for all specs discussed in this presentation 
Defers to native impls, when present 
So, You can use all of these cool specs now!
The first devolving framework 
Less important as Web Components et al. coverage increases 
Should disappear when these specs are implemented 
everywhere
A polyfill for Shadow DOM? 
How? 
It's complicated 
Everything is wrapped 
Required to: 
maintain encapsulation 
maintain separation between light & shadow DOM elements 
retarget events originally destined for the shadow DOM tree
file-input 
Web Component built using Polymer 
Allows <input type='file'> to be easily styled 
Built-in file validation 
More intuitive access to (valid) files
e.g. 
<file-input class="btn btn-primary" 
extensions='["jpeg", "jpg"]' 
minSize="500000" 
maxSize="3000000"> 
<span class="glyphicon glyphicon-file"></span> 
Select a file 
</file-input>
ajax-form 
Web Component built using Polymer 
Submit a form without a page reload 
Send custom headers w/ form submit 
Easy access to server response 
Dirt simple validation support/control 
Submit <file-input> elements too!
e.g. 
<form is="ajax-form" 
method="POST" 
action="form/handler" 
headers='{"X-Cust-Header": "FooBar"}'> 
<input type="text" name="fullname" required> 
<input type="submit"> 
</form> 
form.addEventListener('submitted', 
function(e) { 
if (event.detail.status > 299) { 
// submit may have failed 
} 
} 
); 
form.addEventListener('invalid', 
function(e) { 
e.detail.forEach(function(badEl) { 
// do something w/ invalid element 
}); 
} 
);
Useful Links 
WeakMap 
Information hiding with WeakMaps 
Object.observe 
MutationObserver 
Web Components 
custom elements 
Polymer 
<form is="ajax-form"> 
<file-input>

More Related Content

What's hot

Web Development with NodeJS
Web Development with NodeJSWeb Development with NodeJS
Web Development with NodeJSRiza Fahmi
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Librarynaohito maeda
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web PerformanceAdam Lu
 
Difference between java script and jquery
Difference between java script and jqueryDifference between java script and jquery
Difference between java script and jqueryUmar Ali
 
Mojo – Simple REST Server
Mojo – Simple REST ServerMojo – Simple REST Server
Mojo – Simple REST Serverhendrikvb
 
Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14mattsmcnulty
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationAndrew Rota
 
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...Sencha
 
Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)Hendrik Ebbers
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Javascript Application Architecture with Backbone.JS
Javascript Application Architecture with Backbone.JSJavascript Application Architecture with Backbone.JS
Javascript Application Architecture with Backbone.JSMin Ming Lo
 
iPhone project - Wireless networks seminar
iPhone project - Wireless networks seminariPhone project - Wireless networks seminar
iPhone project - Wireless networks seminarSilvio Daminato
 
Ajax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesAjax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesDoris Chen
 

What's hot (20)

Web Development with NodeJS
Web Development with NodeJSWeb Development with NodeJS
Web Development with NodeJS
 
Grails and Ajax
Grails and AjaxGrails and Ajax
Grails and Ajax
 
Web components
Web componentsWeb components
Web components
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Library
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
 
Difference between java script and jquery
Difference between java script and jqueryDifference between java script and jquery
Difference between java script and jquery
 
Mojo – Simple REST Server
Mojo – Simple REST ServerMojo – Simple REST Server
Mojo – Simple REST Server
 
Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
 
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)
 
Google Polymer Framework
Google Polymer FrameworkGoogle Polymer Framework
Google Polymer Framework
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Javascript Application Architecture with Backbone.JS
Javascript Application Architecture with Backbone.JSJavascript Application Architecture with Backbone.JS
Javascript Application Architecture with Backbone.JS
 
Speed up your GWT coding with gQuery
Speed up your GWT coding with gQuerySpeed up your GWT coding with gQuery
Speed up your GWT coding with gQuery
 
iPhone project - Wireless networks seminar
iPhone project - Wireless networks seminariPhone project - Wireless networks seminar
iPhone project - Wireless networks seminar
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Ajax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesAjax Performance Tuning and Best Practices
Ajax Performance Tuning and Best Practices
 
Break out of The Box - Part 2
Break out of The Box - Part 2Break out of The Box - Part 2
Break out of The Box - Part 2
 

Similar to The Future of the Web

Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJsTudor Barbu
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slideshelenmga
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the futureDA-14
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinSimon Gauvin
 
Desbravando Web Components
Desbravando Web ComponentsDesbravando Web Components
Desbravando Web ComponentsMateus Ortiz
 
The Road to Native Web Components
The Road to Native Web ComponentsThe Road to Native Web Components
The Road to Native Web ComponentsMike North
 
Michael North "The Road to Native Web Components"
Michael North "The Road to Native Web Components"Michael North "The Road to Native Web Components"
Michael North "The Road to Native Web Components"Fwdays
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupDavid Barreto
 
Modern Web Technologies
Modern Web TechnologiesModern Web Technologies
Modern Web TechnologiesPerttu Myry
 
Polymer - Lego for the web!
Polymer - Lego for the web!Polymer - Lego for the web!
Polymer - Lego for the web!Codemotion
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
Rawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance TipsRavi Raj
 
Academy PRO: HTML5 API Introduction
Academy PRO: HTML5 API IntroductionAcademy PRO: HTML5 API Introduction
Academy PRO: HTML5 API IntroductionBinary Studio
 

Similar to The Future of the Web (20)

Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slides
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
Desbravando Web Components
Desbravando Web ComponentsDesbravando Web Components
Desbravando Web Components
 
The Road to Native Web Components
The Road to Native Web ComponentsThe Road to Native Web Components
The Road to Native Web Components
 
Michael North "The Road to Native Web Components"
Michael North "The Road to Native Web Components"Michael North "The Road to Native Web Components"
Michael North "The Road to Native Web Components"
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
Modern Web Technologies
Modern Web TechnologiesModern Web Technologies
Modern Web Technologies
 
Polymer - Lego for the web!
Polymer - Lego for the web!Polymer - Lego for the web!
Polymer - Lego for the web!
 
IOC + Javascript
IOC + JavascriptIOC + Javascript
IOC + Javascript
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
Rawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web Components
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance Tips
 
前端概述
前端概述前端概述
前端概述
 
React js
React jsReact js
React js
 
ReactJS.ppt
ReactJS.pptReactJS.ppt
ReactJS.ppt
 
Academy PRO: HTML5 API Introduction
Academy PRO: HTML5 API IntroductionAcademy PRO: HTML5 API Introduction
Academy PRO: HTML5 API Introduction
 

Recently uploaded

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Recently uploaded (20)

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

The Future of the Web

  • 1. The Future of the Web ...and the one polyfill that makes it all possible today
  • 2. Browser Support WeakMap: Chrome, FF, IE11 Object.observe: Chrome 36 MutationObserver: all but IE10, Safari 6.1, Android 4.3 Web Components: Chrome 36, FF 32, Android 4.4
  • 3. WeakMap keys are objects values can be anything does not prevent garbage collection of keys
  • 4. Use Cases Associate data with an element w/out augmenting the element Associate data with a read-only object More efficient information hiding
  • 5. e.g. var map = new WeakMap(); var someEl = document.getElementById('someEl'); map.set(someEl, {foo: 'bar'}); if (map.has(document.getElementById('someEl') { map.get(someEl).foo; // bar }
  • 6. Object.observe Receive callbacks when an object changes in any way Native impl for Angular's scope.$watch For Arrays: Array.observe Angular will delegate in 2.0
  • 7. Angular scope.name = 'Ray'; scope.$watch('name', function(newV, oldV) { console.log('old name: ' + oldV); console.log('new name: ' + newV); });
  • 8. Native scope.name = "Ray"; Object.observe(scope, function(change) { if (change.name === 'name') { console.log('old name: ' + change.oldValue); console.log('new value: ' + change.object[change.name]); } });
  • 9. MutationObserver Receive callbacks when an element changes in any way Element descendendants can also be observed Replacement for inefficient Mutation Events
  • 10. e.g. var callback = function(records) { var record = records[0]; // for demo simplicity only var added = record.addedNodes; if (added.length) { var newTags = 0; for (var i = 0; i < added.length; i++) { if (added[i].className.indexOf('tag') >= 0) { newTags++; } } if (newTags) { alert(newTags + " new tags added."); } } }; var observer = new MutationObserver(callback); observer.observe(tagsContainerEl, {childList: true});
  • 11. Web Components Templates Custom Elements Shadow DOM
  • 12. Templates Create re-usable content <template> is not rendered, must be "activated" Any elements can be children <template> <div>hi there</div> <div>you can't see me right now</div> <blink>luckily for you</blink> </template> Live example [jsbin]
  • 13. HTML Imports Pull another HTML file into the current document Inject a packaged component (and all deps) w/ one line Re-use templates stored in a central location <link rel="import" href="/license.html">
  • 14. Using an imported document // Grab the <link> that imports the licensing blurb var licensingLink = document.getElementById('licenseLink'); // Grab the relevant content from the imported doc var content = licensingLink.import.getElementById('license'); // Append the content to our doc document.body.appendChild(content); NOTE: Server must return proper CORS headers for cross-domain imports Complete example [jsbin]
  • 15. Custom Elements <my-custom-element></my-custom-element> MUST contain a dash Take heed angular directive writers. Use ember? You're cool. Why? To avoid conflict w/ future standardized elements.
  • 16. Creating Custom Elements Initially an :unresolved HTMLElement To "resolve", you must document.registerElement Two types: 1. New* CE 2. Type Extension CE * I just made up this name
  • 17. Standard Custom Element <foo-bar> <!-- unresolved content --> </foo-bar> <script> </script> Live example [jsbin]
  • 18. Type Extension Custom Element <video is="frame-grabber" src="somevideo.mp4"> </video> var frameGrabber = document.createElement('video', 'frame-grabber'); frameGrabber.prototype.grab = function() { // grab current frame & do something w/ it }
  • 19. Shadow DOM Allows creation of self-contained, sandboxed web components A single Node can now be made up of 3 different subtrees: Light DOM Shadow DOM Composed DOM
  • 20. Light DOM Tree Part of the "logical DOM" Content of the custom element provided by integrator <blink-is-back> Bring back the blink tag! </blink-is-back> Displayed pre-shadow-root render
  • 21. Shadow DOM Tree Part of the "logical DOM" Internal to the custom element, not a child Not directly accessible via the light DOM 1. Include element on page 2. Register (if CE) 3. myElement.createShadowRoot(); 4. Append content to shadow root 5. Live example [jsbin]
  • 22. Composed DOM Tree Content that is actually rendered Pieces of the light and shadow DOM combined Composed DOM from the <blink-is-back> CE: <blink-is-back> <div style="text-decoration: line-through;"> Bring back the blink element! </div> <div>But seriously, don't make text blink.</div> </blink-is-back>
  • 23. Polymer Shim for all specs discussed in this presentation Defers to native impls, when present So, You can use all of these cool specs now!
  • 24. The first devolving framework Less important as Web Components et al. coverage increases Should disappear when these specs are implemented everywhere
  • 25. A polyfill for Shadow DOM? How? It's complicated Everything is wrapped Required to: maintain encapsulation maintain separation between light & shadow DOM elements retarget events originally destined for the shadow DOM tree
  • 26. file-input Web Component built using Polymer Allows <input type='file'> to be easily styled Built-in file validation More intuitive access to (valid) files
  • 27. e.g. <file-input class="btn btn-primary" extensions='["jpeg", "jpg"]' minSize="500000" maxSize="3000000"> <span class="glyphicon glyphicon-file"></span> Select a file </file-input>
  • 28. ajax-form Web Component built using Polymer Submit a form without a page reload Send custom headers w/ form submit Easy access to server response Dirt simple validation support/control Submit <file-input> elements too!
  • 29. e.g. <form is="ajax-form" method="POST" action="form/handler" headers='{"X-Cust-Header": "FooBar"}'> <input type="text" name="fullname" required> <input type="submit"> </form> form.addEventListener('submitted', function(e) { if (event.detail.status > 299) { // submit may have failed } } ); form.addEventListener('invalid', function(e) { e.detail.forEach(function(badEl) { // do something w/ invalid element }); } );
  • 30.
  • 31. Useful Links WeakMap Information hiding with WeakMaps Object.observe MutationObserver Web Components custom elements Polymer <form is="ajax-form"> <file-input>