SlideShare a Scribd company logo

Progressive Enhancement with JavaScript and Ajax

Christian Heilmann
Christian HeilmannSenior Program Manager Developer Experience and Evangelism at Microsoft

My talk for Highland Fling 2007 on Progressive Enhancement with JavaScript

Progressive Enhancement with JavaScript and Ajax

Christian Heilmann
Christian HeilmannSenior Program Manager Developer Experience and Evangelism at Microsoft

My talk for Highland Fling 2007 on Progressive Enhancement with JavaScript

Progressive Enhancement with JavaScript and Ajax

1 of 40
Download to read offline
Progressive
 Enhancement
With JavaScript
       and Ajax




                  Highland Fling 2007
                  Christian Heilmann
• As web developers we are in a
  very lucky position.
• Unlike real world products,
  web sites do not have a fixed
  state.
• Web documents were right
  from the start meant to be
  adaptive to their environment.
• By keeping things flexible and
  adaptive we can please all
  consumers.

                                   http://www.flickr.com/photos/oskay/420878465/
• Real life enhancement
• Real life has some ideas of
  progressive enhancement,
  most of which are old
  chestnuts:
  – Measure twice, cut once.
  – Check the depth of the lake
    before you plunge in.
  – Try before you buy
  – = Use Bittorrent
• The same logic applies to
  JavaScript and Ajax:
  – Test if JavaScript is available.
  – Test if the DOM is supported
  – Test for the HTML you want to
    use.
  – Test for any object you want to
    use.
  – Don’t rely on the connection to
    be available.
• Testing for JavaScript is easy,
  simply don’t make your
  product rely on JavaScript:
     – Death to href=“javascript:foo()”
     – Death to onclick=“foo()”
     – Who the hell ever told you to
       use onclick=“javascript:foo()” ?

• Don’t mix HTML and
  JavaScript, use the DOM to
  access HTML.
• The DOM is your API to the
  document.
http://www.flickr.com/photos/jungle_boy/140233674/

Recommended

Jazz up your JavaScript: Unobtrusive scripting with JavaScript libraries
Jazz up your JavaScript: Unobtrusive scripting with JavaScript librariesJazz up your JavaScript: Unobtrusive scripting with JavaScript libraries
Jazz up your JavaScript: Unobtrusive scripting with JavaScript librariesSimon Willison
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for youSimon Willison
 
Performance & Responsive Web Design
Performance & Responsive Web DesignPerformance & Responsive Web Design
Performance & Responsive Web DesignZach Leatherman
 
Build Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićBuild Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićMeetMagentoNY2014
 
Netvibes UWA workshop at ParisWeb 2007
Netvibes UWA workshop at ParisWeb 2007Netvibes UWA workshop at ParisWeb 2007
Netvibes UWA workshop at ParisWeb 2007Netvibes
 

More Related Content

What's hot

Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOMDaiwei Lu
 
JavaScript DOM Manipulations
JavaScript DOM ManipulationsJavaScript DOM Manipulations
JavaScript DOM ManipulationsYnon Perek
 
jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009Ralph Whitbeck
 
Taiwan Web Standards Talk 2011
Taiwan Web Standards Talk 2011Taiwan Web Standards Talk 2011
Taiwan Web Standards Talk 2011Zi Bin Cheah
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterpriseDave Artz
 
10 java script projects full source code
10 java script projects full source code10 java script projects full source code
10 java script projects full source codeLaurence Svekis ✔
 
Google’s PRPL Web development pattern
Google’s PRPL Web development patternGoogle’s PRPL Web development pattern
Google’s PRPL Web development patternJeongkyu Shin
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)jeresig
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web ComponentsAndrew Rota
 
The Fine Art of JavaScript Event Handling
The Fine Art of JavaScript Event HandlingThe Fine Art of JavaScript Event Handling
The Fine Art of JavaScript Event HandlingYorick Phoenix
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)jeresig
 
1 ppt-ajax with-j_query
1 ppt-ajax with-j_query1 ppt-ajax with-j_query
1 ppt-ajax with-j_queryFajar Baskoro
 
When dynamic becomes static - the next step in web caching techniques
When dynamic becomes static - the next step in web caching techniquesWhen dynamic becomes static - the next step in web caching techniques
When dynamic becomes static - the next step in web caching techniquesWim Godden
 
jQuery and the W3C
jQuery and the W3CjQuery and the W3C
jQuery and the W3Cjeresig
 

What's hot (20)

Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOM
 
JavaScript DOM Manipulations
JavaScript DOM ManipulationsJavaScript DOM Manipulations
JavaScript DOM Manipulations
 
jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Taiwan Web Standards Talk 2011
Taiwan Web Standards Talk 2011Taiwan Web Standards Talk 2011
Taiwan Web Standards Talk 2011
 
Javascript and DOM
Javascript and DOMJavascript and DOM
Javascript and DOM
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
10 java script projects full source code
10 java script projects full source code10 java script projects full source code
10 java script projects full source code
 
Google’s PRPL Web development pattern
Google’s PRPL Web development patternGoogle’s PRPL Web development pattern
Google’s PRPL Web development pattern
 
Backbone
BackboneBackbone
Backbone
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
 
The Fine Art of JavaScript Event Handling
The Fine Art of JavaScript Event HandlingThe Fine Art of JavaScript Event Handling
The Fine Art of JavaScript Event Handling
 
Vue.js for beginners
Vue.js for beginnersVue.js for beginners
Vue.js for beginners
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)
 
1 ppt-ajax with-j_query
1 ppt-ajax with-j_query1 ppt-ajax with-j_query
1 ppt-ajax with-j_query
 
When dynamic becomes static - the next step in web caching techniques
When dynamic becomes static - the next step in web caching techniquesWhen dynamic becomes static - the next step in web caching techniques
When dynamic becomes static - the next step in web caching techniques
 
jQuery and the W3C
jQuery and the W3CjQuery and the W3C
jQuery and the W3C
 

Similar to Progressive Enhancement with JavaScript and Ajax

Building a JavaScript Library
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Libraryjeresig
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for youSimon Willison
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSNaga Harish M
 
The road to professional web development
The road to professional web developmentThe road to professional web development
The road to professional web developmentChristian Heilmann
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend TestingNeil Crosby
 
Learning jQuery @ MIT
Learning jQuery @ MITLearning jQuery @ MIT
Learning jQuery @ MITjeresig
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQueryDanWooster1
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone InteractivityEric Steele
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptKevin Read
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Kevin Read
 
Intro To Django
Intro To DjangoIntro To Django
Intro To DjangoUdi Bauman
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoiddmethvin
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyondmguillem
 
JavaScript 2.0 in Dreamweaver CS4
JavaScript 2.0 in Dreamweaver CS4JavaScript 2.0 in Dreamweaver CS4
JavaScript 2.0 in Dreamweaver CS4alexsaves
 
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScaleGDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScalePatrick Chanezon
 
Usability in the GeoWeb
Usability in the GeoWebUsability in the GeoWeb
Usability in the GeoWebDave Bouwman
 
jQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsjQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsEugene Andruszczenko
 

Similar to Progressive Enhancement with JavaScript and Ajax (20)

Seven Reasons for Code Bloat
Seven Reasons for Code BloatSeven Reasons for Code Bloat
Seven Reasons for Code Bloat
 
Building a JavaScript Library
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Library
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 
The road to professional web development
The road to professional web developmentThe road to professional web development
The road to professional web development
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
 
Learning jQuery @ MIT
Learning jQuery @ MITLearning jQuery @ MIT
Learning jQuery @ MIT
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScript
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8
 
Shifting Gears
Shifting GearsShifting Gears
Shifting Gears
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
 
JavaScript 2.0 in Dreamweaver CS4
JavaScript 2.0 in Dreamweaver CS4JavaScript 2.0 in Dreamweaver CS4
JavaScript 2.0 in Dreamweaver CS4
 
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScaleGDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
 
Usability in the GeoWeb
Usability in the GeoWebUsability in the GeoWeb
Usability in the GeoWeb
 
jQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsjQuery Presentation - Refresh Events
jQuery Presentation - Refresh Events
 

More from Christian Heilmann

Develop, Debug, Learn? - Dotjs2019
Develop, Debug, Learn? - Dotjs2019Develop, Debug, Learn? - Dotjs2019
Develop, Debug, Learn? - Dotjs2019Christian Heilmann
 
Taking the "vile" out of privilege
Taking the "vile" out of privilegeTaking the "vile" out of privilege
Taking the "vile" out of privilegeChristian Heilmann
 
Seven ways to be a happier JavaScript developer - NDC Oslo
Seven ways to be a happier JavaScript developer - NDC OsloSeven ways to be a happier JavaScript developer - NDC Oslo
Seven ways to be a happier JavaScript developer - NDC OsloChristian Heilmann
 
Artificial intelligence for humans… #AIDC2018 keynote
Artificial intelligence for humans… #AIDC2018 keynoteArtificial intelligence for humans… #AIDC2018 keynote
Artificial intelligence for humans… #AIDC2018 keynoteChristian Heilmann
 
Killing the golden calf of coding - We are Developers keynote
Killing the golden calf of coding - We are Developers keynoteKilling the golden calf of coding - We are Developers keynote
Killing the golden calf of coding - We are Developers keynoteChristian Heilmann
 
Progressive Web Apps - Techdays Finland
Progressive Web Apps - Techdays FinlandProgressive Web Apps - Techdays Finland
Progressive Web Apps - Techdays FinlandChristian Heilmann
 
Taking the "vile" out of privilege
Taking the "vile" out of privilegeTaking the "vile" out of privilege
Taking the "vile" out of privilegeChristian Heilmann
 
Five ways to be a happier JavaScript developer
Five ways to be a happier JavaScript developerFive ways to be a happier JavaScript developer
Five ways to be a happier JavaScript developerChristian Heilmann
 
Sacrificing the golden calf of "coding"
Sacrificing the golden calf of "coding"Sacrificing the golden calf of "coding"
Sacrificing the golden calf of "coding"Christian Heilmann
 
You learned JavaScript - now what?
You learned JavaScript - now what?You learned JavaScript - now what?
You learned JavaScript - now what?Christian Heilmann
 
Sacrificing the golden calf of "coding"
Sacrificing the golden calf of "coding"Sacrificing the golden calf of "coding"
Sacrificing the golden calf of "coding"Christian Heilmann
 
Progressive Web Apps - Covering the best of both worlds - DevReach
Progressive Web Apps - Covering the best of both worlds - DevReachProgressive Web Apps - Covering the best of both worlds - DevReach
Progressive Web Apps - Covering the best of both worlds - DevReachChristian Heilmann
 
Progressive Web Apps - Covering the best of both worlds
Progressive Web Apps - Covering the best of both worldsProgressive Web Apps - Covering the best of both worlds
Progressive Web Apps - Covering the best of both worldsChristian Heilmann
 
Non-trivial pursuits: Learning machines and forgetful humans
Non-trivial pursuits: Learning machines and forgetful humansNon-trivial pursuits: Learning machines and forgetful humans
Non-trivial pursuits: Learning machines and forgetful humansChristian Heilmann
 
Progressive Web Apps - Bringing the web front and center
Progressive Web Apps - Bringing the web front and center Progressive Web Apps - Bringing the web front and center
Progressive Web Apps - Bringing the web front and center Christian Heilmann
 
CSS vs. JavaScript - Trust vs. Control
CSS vs. JavaScript - Trust vs. ControlCSS vs. JavaScript - Trust vs. Control
CSS vs. JavaScript - Trust vs. ControlChristian Heilmann
 
Leveling up your JavaScipt - DrupalJam 2017
Leveling up your JavaScipt - DrupalJam 2017Leveling up your JavaScipt - DrupalJam 2017
Leveling up your JavaScipt - DrupalJam 2017Christian Heilmann
 
The Soul in The Machine - Developing for Humans (FrankenJS edition)
The Soul in The Machine - Developing for Humans (FrankenJS edition)The Soul in The Machine - Developing for Humans (FrankenJS edition)
The Soul in The Machine - Developing for Humans (FrankenJS edition)Christian Heilmann
 

More from Christian Heilmann (20)

Develop, Debug, Learn? - Dotjs2019
Develop, Debug, Learn? - Dotjs2019Develop, Debug, Learn? - Dotjs2019
Develop, Debug, Learn? - Dotjs2019
 
Hinting at a better web
Hinting at a better webHinting at a better web
Hinting at a better web
 
Taking the "vile" out of privilege
Taking the "vile" out of privilegeTaking the "vile" out of privilege
Taking the "vile" out of privilege
 
Seven ways to be a happier JavaScript developer - NDC Oslo
Seven ways to be a happier JavaScript developer - NDC OsloSeven ways to be a happier JavaScript developer - NDC Oslo
Seven ways to be a happier JavaScript developer - NDC Oslo
 
Artificial intelligence for humans… #AIDC2018 keynote
Artificial intelligence for humans… #AIDC2018 keynoteArtificial intelligence for humans… #AIDC2018 keynote
Artificial intelligence for humans… #AIDC2018 keynote
 
Killing the golden calf of coding - We are Developers keynote
Killing the golden calf of coding - We are Developers keynoteKilling the golden calf of coding - We are Developers keynote
Killing the golden calf of coding - We are Developers keynote
 
Progressive Web Apps - Techdays Finland
Progressive Web Apps - Techdays FinlandProgressive Web Apps - Techdays Finland
Progressive Web Apps - Techdays Finland
 
Taking the "vile" out of privilege
Taking the "vile" out of privilegeTaking the "vile" out of privilege
Taking the "vile" out of privilege
 
Five ways to be a happier JavaScript developer
Five ways to be a happier JavaScript developerFive ways to be a happier JavaScript developer
Five ways to be a happier JavaScript developer
 
Taking the P out of PWA
Taking the P out of PWATaking the P out of PWA
Taking the P out of PWA
 
Sacrificing the golden calf of "coding"
Sacrificing the golden calf of "coding"Sacrificing the golden calf of "coding"
Sacrificing the golden calf of "coding"
 
You learned JavaScript - now what?
You learned JavaScript - now what?You learned JavaScript - now what?
You learned JavaScript - now what?
 
Sacrificing the golden calf of "coding"
Sacrificing the golden calf of "coding"Sacrificing the golden calf of "coding"
Sacrificing the golden calf of "coding"
 
Progressive Web Apps - Covering the best of both worlds - DevReach
Progressive Web Apps - Covering the best of both worlds - DevReachProgressive Web Apps - Covering the best of both worlds - DevReach
Progressive Web Apps - Covering the best of both worlds - DevReach
 
Progressive Web Apps - Covering the best of both worlds
Progressive Web Apps - Covering the best of both worldsProgressive Web Apps - Covering the best of both worlds
Progressive Web Apps - Covering the best of both worlds
 
Non-trivial pursuits: Learning machines and forgetful humans
Non-trivial pursuits: Learning machines and forgetful humansNon-trivial pursuits: Learning machines and forgetful humans
Non-trivial pursuits: Learning machines and forgetful humans
 
Progressive Web Apps - Bringing the web front and center
Progressive Web Apps - Bringing the web front and center Progressive Web Apps - Bringing the web front and center
Progressive Web Apps - Bringing the web front and center
 
CSS vs. JavaScript - Trust vs. Control
CSS vs. JavaScript - Trust vs. ControlCSS vs. JavaScript - Trust vs. Control
CSS vs. JavaScript - Trust vs. Control
 
Leveling up your JavaScipt - DrupalJam 2017
Leveling up your JavaScipt - DrupalJam 2017Leveling up your JavaScipt - DrupalJam 2017
Leveling up your JavaScipt - DrupalJam 2017
 
The Soul in The Machine - Developing for Humans (FrankenJS edition)
The Soul in The Machine - Developing for Humans (FrankenJS edition)The Soul in The Machine - Developing for Humans (FrankenJS edition)
The Soul in The Machine - Developing for Humans (FrankenJS edition)
 

Recently uploaded

K8 Meetup_ K8s secrets management best practices (Git Guardian).pdf
K8 Meetup_ K8s secrets management best practices (Git Guardian).pdfK8 Meetup_ K8s secrets management best practices (Git Guardian).pdf
K8 Meetup_ K8s secrets management best practices (Git Guardian).pdfMichaelOLeary82
 
Correcting Common Mistakes, AsyncAwait.pptx
Correcting Common Mistakes, AsyncAwait.pptxCorrecting Common Mistakes, AsyncAwait.pptx
Correcting Common Mistakes, AsyncAwait.pptxBrandon Minnick, MBA
 
AI - summary of focus groups.pdf
AI - summary of focus groups.pdfAI - summary of focus groups.pdf
AI - summary of focus groups.pdfDavid Wood
 
Java 21 Language Features and Beyond
Java 21 Language Features and BeyondJava 21 Language Features and Beyond
Java 21 Language Features and BeyondAna-Maria Mihalceanu
 
From Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security EnhancementsFrom Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security EnhancementsAna-Maria Mihalceanu
 
Connector Corner: Connect to your processes with UiPath Integration Service...
Connector Corner: Connect  to your processes  with UiPath Integration Service...Connector Corner: Connect  to your processes  with UiPath Integration Service...
Connector Corner: Connect to your processes with UiPath Integration Service...DianaGray10
 
Charting New Waters: Data Integration Excellence for Port & Marine Operations
Charting New Waters: Data Integration Excellence for Port & Marine OperationsCharting New Waters: Data Integration Excellence for Port & Marine Operations
Charting New Waters: Data Integration Excellence for Port & Marine Operationsmarketing932765
 
Career Talk Series: Session 3- Skill Development and Continuous learning in t...
Career Talk Series: Session 3- Skill Development and Continuous learning in t...Career Talk Series: Session 3- Skill Development and Continuous learning in t...
Career Talk Series: Session 3- Skill Development and Continuous learning in t...DianaGray10
 
Getting AV1/SVC to work in the Janus WebRTC Server
Getting AV1/SVC to work in the Janus WebRTC ServerGetting AV1/SVC to work in the Janus WebRTC Server
Getting AV1/SVC to work in the Janus WebRTC ServerLorenzo Miniero
 
Human Interaction, Emerging Technologies and Future Systems V
Human Interaction, Emerging Technologies and Future Systems VHuman Interaction, Emerging Technologies and Future Systems V
Human Interaction, Emerging Technologies and Future Systems Vkrcdnsqxswifzizvzs
 
DA Holiday Office Parties.pptx
DA Holiday Office Parties.pptxDA Holiday Office Parties.pptx
DA Holiday Office Parties.pptxeg3000
 
Wandavision opening sequence and analysis
Wandavision opening sequence and analysisWandavision opening sequence and analysis
Wandavision opening sequence and analysis17pmat213
 
Presentation - webinar embedded machine learning
Presentation - webinar embedded machine learningPresentation - webinar embedded machine learning
Presentation - webinar embedded machine learningSirris
 
Dataliva Company Brief 2024
Dataliva Company Brief 2024Dataliva Company Brief 2024
Dataliva Company Brief 2024Mustafa Kuğu
 
Transcript: New stores, new views: Booksellers adapting engaging and thriving...
Transcript: New stores, new views: Booksellers adapting engaging and thriving...Transcript: New stores, new views: Booksellers adapting engaging and thriving...
Transcript: New stores, new views: Booksellers adapting engaging and thriving...BookNet Canada
 
Stage 1 Tradecraft
Stage 1 TradecraftStage 1 Tradecraft
Stage 1 Tradecraftmatt806068
 
CenturyDX-IT-Company
CenturyDX-IT-CompanyCenturyDX-IT-Company
CenturyDX-IT-CompanyMustafa Kuğu
 
Journey to Google
Journey to GoogleJourney to Google
Journey to GoogleGDSC PJATK
 
Unleashing the force of AI-powered intelligent document processing
Unleashing the force of AI-powered intelligent document processingUnleashing the force of AI-powered intelligent document processing
Unleashing the force of AI-powered intelligent document processingUiPathCommunity
 

Recently uploaded (20)

K8 Meetup_ K8s secrets management best practices (Git Guardian).pdf
K8 Meetup_ K8s secrets management best practices (Git Guardian).pdfK8 Meetup_ K8s secrets management best practices (Git Guardian).pdf
K8 Meetup_ K8s secrets management best practices (Git Guardian).pdf
 
Correcting Common Mistakes, AsyncAwait.pptx
Correcting Common Mistakes, AsyncAwait.pptxCorrecting Common Mistakes, AsyncAwait.pptx
Correcting Common Mistakes, AsyncAwait.pptx
 
AI - summary of focus groups.pdf
AI - summary of focus groups.pdfAI - summary of focus groups.pdf
AI - summary of focus groups.pdf
 
Java 21 Language Features and Beyond
Java 21 Language Features and BeyondJava 21 Language Features and Beyond
Java 21 Language Features and Beyond
 
From Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security EnhancementsFrom Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security Enhancements
 
Connector Corner: Connect to your processes with UiPath Integration Service...
Connector Corner: Connect  to your processes  with UiPath Integration Service...Connector Corner: Connect  to your processes  with UiPath Integration Service...
Connector Corner: Connect to your processes with UiPath Integration Service...
 
Charting New Waters: Data Integration Excellence for Port & Marine Operations
Charting New Waters: Data Integration Excellence for Port & Marine OperationsCharting New Waters: Data Integration Excellence for Port & Marine Operations
Charting New Waters: Data Integration Excellence for Port & Marine Operations
 
Career Talk Series: Session 3- Skill Development and Continuous learning in t...
Career Talk Series: Session 3- Skill Development and Continuous learning in t...Career Talk Series: Session 3- Skill Development and Continuous learning in t...
Career Talk Series: Session 3- Skill Development and Continuous learning in t...
 
Getting AV1/SVC to work in the Janus WebRTC Server
Getting AV1/SVC to work in the Janus WebRTC ServerGetting AV1/SVC to work in the Janus WebRTC Server
Getting AV1/SVC to work in the Janus WebRTC Server
 
Human Interaction, Emerging Technologies and Future Systems V
Human Interaction, Emerging Technologies and Future Systems VHuman Interaction, Emerging Technologies and Future Systems V
Human Interaction, Emerging Technologies and Future Systems V
 
DA Holiday Office Parties.pptx
DA Holiday Office Parties.pptxDA Holiday Office Parties.pptx
DA Holiday Office Parties.pptx
 
Recon for Bug Bounty by Agnibha Dutta.pdf
Recon for Bug Bounty by Agnibha  Dutta.pdfRecon for Bug Bounty by Agnibha  Dutta.pdf
Recon for Bug Bounty by Agnibha Dutta.pdf
 
Wandavision opening sequence and analysis
Wandavision opening sequence and analysisWandavision opening sequence and analysis
Wandavision opening sequence and analysis
 
Presentation - webinar embedded machine learning
Presentation - webinar embedded machine learningPresentation - webinar embedded machine learning
Presentation - webinar embedded machine learning
 
Dataliva Company Brief 2024
Dataliva Company Brief 2024Dataliva Company Brief 2024
Dataliva Company Brief 2024
 
Transcript: New stores, new views: Booksellers adapting engaging and thriving...
Transcript: New stores, new views: Booksellers adapting engaging and thriving...Transcript: New stores, new views: Booksellers adapting engaging and thriving...
Transcript: New stores, new views: Booksellers adapting engaging and thriving...
 
Stage 1 Tradecraft
Stage 1 TradecraftStage 1 Tradecraft
Stage 1 Tradecraft
 
CenturyDX-IT-Company
CenturyDX-IT-CompanyCenturyDX-IT-Company
CenturyDX-IT-Company
 
Journey to Google
Journey to GoogleJourney to Google
Journey to Google
 
Unleashing the force of AI-powered intelligent document processing
Unleashing the force of AI-powered intelligent document processingUnleashing the force of AI-powered intelligent document processing
Unleashing the force of AI-powered intelligent document processing
 

Progressive Enhancement with JavaScript and Ajax

  • 1. Progressive Enhancement With JavaScript and Ajax Highland Fling 2007 Christian Heilmann
  • 2. • As web developers we are in a very lucky position. • Unlike real world products, web sites do not have a fixed state. • Web documents were right from the start meant to be adaptive to their environment. • By keeping things flexible and adaptive we can please all consumers. http://www.flickr.com/photos/oskay/420878465/
  • 3. • Real life enhancement
  • 4. • Real life has some ideas of progressive enhancement, most of which are old chestnuts: – Measure twice, cut once. – Check the depth of the lake before you plunge in. – Try before you buy – = Use Bittorrent
  • 5. • The same logic applies to JavaScript and Ajax: – Test if JavaScript is available. – Test if the DOM is supported – Test for the HTML you want to use. – Test for any object you want to use. – Don’t rely on the connection to be available.
  • 6. • Testing for JavaScript is easy, simply don’t make your product rely on JavaScript: – Death to href=“javascript:foo()” – Death to onclick=“foo()” – Who the hell ever told you to use onclick=“javascript:foo()” ? • Don’t mix HTML and JavaScript, use the DOM to access HTML. • The DOM is your API to the document. http://www.flickr.com/photos/jungle_boy/140233674/
  • 7. • Testing for DOM support is as easy: – Check that getElementById and is available. – If you still care about Opera 6 also test for createTextNode function init(){ if( document.getElementById && document.createTextNode ) // we have DOM, wahey! checkDependencies(); } }
  • 8. • Testing for the HTML you need is also easy: – Check that all the elements are available. function checkDependencies(){ var usedIds = ['nav','content']; var isOk = true; for(var i = 0; usedIds[i]!==undefined; i++) { if( !document.getElementById( usedIds[i] ) ){ isOk = false; } } return isOk; }
  • 9. • Testing for the HTML you need is also easy: – Check that all the elements are available. – Check that they also have the right child nodes function myNavStuff(){ var n = document.getElementById('nav'); if(n.getElementsByTagName('ul').length > 0){ // I got your code right here! } }
  • 10. • Testing for object availability – Simply test for any object before you access it var request; try{ request = new XMLHttpRequest(); }catch(error){ try{ request = new ActiveXObject(quot;Microsoft.XMLHTTPquot;); }catch(error){ return true; } }
  • 11. • Prepare for unreliable and flaky connections. – Set a timer to time out and abort the connection after a certain period has passed. – Define a success and failure case for any connection. – Make sure you avoid caching issues by setting an expired HTTP header on your Ajax calls
  • 12. • This is the “how” of progressive enhancement with JavaScript and Ajax. • The question however is why use JavaScript at all? • After all it can be turned off.
  • 13. • Instead we can use the amazing new trick called “CSS only solutions”. • Why bother with writing complex scripts when you can do the same with some easy lines of CSS? • Showing and hiding menus? #nav li ul { display:none } #nav li:hover ul { display:block }
  • 14. • Using CSS for behaviour is based on one trick, which is pseudo selectors like :hover, :active and :focus • These have several problems: – Some browsers only support them on interactive elements like links and buttons. – They have a strict on or off state. – and they fail for a certain user group…
  • 15. • Keyboard access support in HTML and browsers is bad. • Support for :active and :focus is even worse. • Which means that CSS only solutions with keyboard support turn out to be HTML soup nightmares (nesting tables inside links…)
  • 17. • In essence, CSS only solutions are a bit of a shifty character and you don’t know if you can trust them. • It is also debateable if CSS only solutions are in the end easier than JS solutions.
  • 18. • JavaScript has so many more options for you: – Real testing for support of objects – Real event handling including simulation of application keyboard handling (cursors instead of tabbing) – timeout() to allow for user errors – Creation of necessary markup on demand.
  • 19. • JavaScript has so many more options for you: – Test of available screen estate – Loading of extra content on demand http://www.flickr.com/photos/drewm/227562632/
  • 21. • Does this mean that only scripters should create interfaces and CSS is not needed? • Not at all, as first of all CSS can help JavaScript a lot. http://www.flickr.com/photos/drewm/225911999/in/set-507727/
  • 22. • Task: Hide all list items in the first UL – A lot of code, that one… window.onload = function(){ if(document.getElementById && document.createTextNode){ var uls = document.getElementsByTagName('ul'); if(uls.length > 0){ var lis = uls[0].getElementsByTagName('li'); for(var i = 0, j = lis.length; i < j; i++){ lis[i].style.display = 'none'; } } } }
  • 23. • Task: Hide all list items in the first UL – How about leaving the main job to the CSS parser? window.onload = function(){ if(document.getElementById && document.createTextNode){ var b = document.body; b.className += b.className ? ' dynamic' : 'dynamic'; } } <style type=quot;text/cssquot;> body.dynamic ul li{ display:none; } </style>
  • 24. • This also allows you to keep the whole look and feel of your scripts in the hands of the CSS maintainers. • All you need to do is make sure you communicate the class and ID names with them.
  • 25. • You achieve highest flexibility by separating those and the text labels out into own includes: slideshow.js slideshow-css.js slideshow-labels.js slideshow.css = { 'navigationID':'nav', 'contentID':'main', 'hide class':'hide' }
  • 26. • There is a danger in progressive enhancement with JavaScript though: • Be aware that what you enhance is as important as how you enhance it. • A solution that doesn’t really make sense shouldn’t be enhanced, but changed.
  • 27. • Useless progressive enhancement. Pointless name dropping Get on with it…
  • 28. • It is important to know your audience • It is important to keep up with technology as a lot of truths of the past are not applicable any longer.
  • 29. • Research what can be enhanced and how. • Example “connected select boxes”:
  • 30. • Research what can be enhanced and how. • Example “hcard to Googlemap”
  • 31. • So why isn’t progressive enhancement yet a common practice? http://www.flickr.com/photos/urlgirl/199044322/
  • 33. • Stockholm Syndrome • Enhanced interfaces don’t go down too well with the mainstream audience, we are used to waiting and things breaking. • Technologies are perceived as given, no need to improve them.
  • 34. • Monetary reasons • Progressive Enhancement costs money • As with any best practice there is no immediate tangible benefit
  • 35. • Show desire • You can help to change this • Look at things, and see how you can improve them • If need be, do it on the sly (hcard in Yahoo! Local)
  • 36. • Benefit from experience of others • A lot of tricks that helped us in the past can be brushed up and renewed now. • Example “lowsrc”
  • 37. • Keep your feelers out there. • Read up on technologies and what is done with them. • Hot: – http://www.w3.org/TR/aria- roadmap/ – http://www.whatwg.org/
  • 38. • Contact, subscribe, talk, share. • If you know something, please tell others: http://makemeaspeaker.com
  • 39. • Good progressive enhancement helps the user, and not the developer. – Automatic saving of drafts in email apps – Parallel upload of content while you can add meta data – Making it easy and fun to add content. – Preventing unnecessary steps. http://www.flickr.com/photos/radiofree/286343390/