SlideShare a Scribd company logo
Unobtrusive javascript
ïŹ JavaScript guru Douglas Crockford calls the
browser “the most hostile programming
environment in the world.”
ïŹ He said this before mobile browsing was even a
thing at which point he said:
ïŹ “I used to say that the web browser was the
most hostile programming environment ever
devised, but that was before I found out about
Mobile.”
ïŹ Infinite combinations of hardware and software
The front end stack
HTML
ïŹ HTML is forgiving and browsers can deal with
invalid markup
ïŹ Markup that doesn't meet the spec will still give
you a mostly working page
CSS
ïŹ CSS is aloof. If it encounters something it
doesn't understand, it just shrugs and moves on
ïŹ Some IE CSS hacks take advantage of CSS
quirks (It's not a bug, it's a feature)
Javascript
ïŹ Javascript is a quitter. If it encounters a problem it just
gives up and goes on strike.
ïŹ Some browsers may ignore your script completely
ïŹ Even when a browser can support JavaScript, users may
turn it off for security reasons, or their corporate firewall
may block it
ïŹ Even when a browser supports JavaScript, it may not
understand parts of your script because it has a
proprietary implementation of some parts of the DOM
specification (usually IE)
ïŹ Even when the script is interpreted correctly, it may
depend on HTML that is very complicated and/or might
change in unpredictable ways.
A lesson from history
First world problems
ïŹ Last February the download button for google
chrome broke.
ïŹ Nobody could download chrome for 12 hours
ïŹ It was caused by a javascript error
ïŹ This was an easy problem to avoid
What went wrong?
ïŹ Somebody broke an unrelated javascript library
used by the google chrome website and
included in all pages
ïŹ Uncaught TypeError: Cannot read property
'value' of undefined
ïŹ Because google did not include a href, the
browser could do nothing except sit there
looking embarrassed
No href
What google did wrong
ïŹ Didn't follow the rules of unobtrusive javascript
ïŹ Created a single point of failure
ïŹ Ignored web standards
ïŹ Trusted core functionality to the most fragile
part of the front end stack
Why do you hate javascript?
ïŹ Javascript is great
ïŹ But don't start with it
ïŹ It's like building a house by choosing the
wallpaper first
ïŹ The purpose of JavaScript is to add a layer of
usability to your site. If the script is the entire
usability layer (in other words, if the site is
unusable without JavaScript), your javascript is
not unobtrusive.
Principles of unobtrusive javascript
ïŹ Your site should work without JavaScript.
ïŹ If JavaScript happens to be enabled, you can
present your users with an extra layer of
usability; a layer that allows them to perform
their tasks more quickly, and that avoids jarring
page reloads where possible.
ïŹ JavaScript is unsafe. That is, you should
*never* trust in JavaScript-only routines for
crucial tasks such as checking user input in a
form.
p.s. Google still don't have a href on that link.
Maybe they invested in better functional tests
instead?

More Related Content

What's hot (20)

PDF
On Selecting JavaScript Frameworks (Women Who Code 10/15)
Zoe Landon
 
PDF
Getting Started with Angular - Stormpath Webinar, January 2017
Matt Raible
 
PDF
JavaScript MV* Framework - Making the Right Choice
Dmitry Sheiko
 
PPTX
Kickstart sencha extjs
Shakti Shrestha
 
PPTX
Cross browser testing with browser stack
Denys Poloka
 
PPT
Smarr Oscon 2007
briandemant
 
PDF
Introduction to Web Development Career
Eunus Hosen
 
PPTX
Java script performance tips
Shakti Shrestha
 
PDF
Testing Angular Applications - Jfokus 2017
Matt Raible
 
ODP
Intro to Web Development
Vinay Shriyan, Certified ScrumMasterÂź (CSM)
 
PPT
Jquery
chauhankapil
 
PPT
Dynamic Website
Ryan Scheel
 
ZIP
Accessible Javascript with and without WAI ARIA
Dirk Ginader
 
PDF
A team 43 C
aldenustream
 
PPTX
WordCamp Denmark Keynote
Frederick Townes
 
PDF
JS Framework Comparison - An infographic
InApp
 
PDF
Staying Connected: Securing Your WordPress Website
Raymund Mitchell
 
PPTX
Performance Tuning Web Apps - The Need For Speed
Vijay Rayapati
 
PDF
Vodafone Widget Camp
Peter-Paul Koch
 
PDF
Intro to Web Development from Bloc.io
Douglas Wright
 
On Selecting JavaScript Frameworks (Women Who Code 10/15)
Zoe Landon
 
Getting Started with Angular - Stormpath Webinar, January 2017
Matt Raible
 
JavaScript MV* Framework - Making the Right Choice
Dmitry Sheiko
 
Kickstart sencha extjs
Shakti Shrestha
 
Cross browser testing with browser stack
Denys Poloka
 
Smarr Oscon 2007
briandemant
 
Introduction to Web Development Career
Eunus Hosen
 
Java script performance tips
Shakti Shrestha
 
Testing Angular Applications - Jfokus 2017
Matt Raible
 
Jquery
chauhankapil
 
Dynamic Website
Ryan Scheel
 
Accessible Javascript with and without WAI ARIA
Dirk Ginader
 
A team 43 C
aldenustream
 
WordCamp Denmark Keynote
Frederick Townes
 
JS Framework Comparison - An infographic
InApp
 
Staying Connected: Securing Your WordPress Website
Raymund Mitchell
 
Performance Tuning Web Apps - The Need For Speed
Vijay Rayapati
 
Vodafone Widget Camp
Peter-Paul Koch
 
Intro to Web Development from Bloc.io
Douglas Wright
 

Similar to Unobtrusive javascript (20)

PDF
PrairieDevCon 2014 - Web Doesn't Mean Slow
dmethvin
 
PDF
Jazz up your JavaScript: Unobtrusive scripting with JavaScript libraries
Simon Willison
 
PPTX
Java script Session No 1
Saif Ullah Dar
 
PDF
Javascript SEO Devs and SEOs playing nicely
Peter Mead
 
PPTX
Upstate CSCI 450 jQuery
DanWooster1
 
PDF
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
PDF
Essential Javascript -- A Javascript <b>Tutorial</b>
tutorialsruby
 
PDF
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
PDF
<img src="../i/r_14.png" />
tutorialsruby
 
PDF
TPR4
tutorialsruby
 
PDF
TPR4
tutorialsruby
 
PDF
Top 8 react static site generators for 2020
Katy Slemon
 
PPTX
Single Page Apps - Gerry White @ BrightonSEO
Gerry White
 
PPTX
What is HTML 5?
Susan Winters
 
PDF
orcreatehappyusers
tutorialsruby
 
PDF
orcreatehappyusers
tutorialsruby
 
PDF
Selecting the Best Javascript Web Framework
Rajitha Pathiraja
 
PDF
Going native with html5 web components
James York
 
PPT
GROOVY ON GRAILS
ziyaaskerov
 
PPTX
7 tips for javascript rich ajax websites
oazabir
 
PrairieDevCon 2014 - Web Doesn't Mean Slow
dmethvin
 
Jazz up your JavaScript: Unobtrusive scripting with JavaScript libraries
Simon Willison
 
Java script Session No 1
Saif Ullah Dar
 
Javascript SEO Devs and SEOs playing nicely
Peter Mead
 
Upstate CSCI 450 jQuery
DanWooster1
 
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
Essential Javascript -- A Javascript <b>Tutorial</b>
tutorialsruby
 
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
<img src="../i/r_14.png" />
tutorialsruby
 
Top 8 react static site generators for 2020
Katy Slemon
 
Single Page Apps - Gerry White @ BrightonSEO
Gerry White
 
What is HTML 5?
Susan Winters
 
orcreatehappyusers
tutorialsruby
 
orcreatehappyusers
tutorialsruby
 
Selecting the Best Javascript Web Framework
Rajitha Pathiraja
 
Going native with html5 web components
James York
 
GROOVY ON GRAILS
ziyaaskerov
 
7 tips for javascript rich ajax websites
oazabir
 
Ad

Recently uploaded (20)

PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
Talbott's brief History of Computers for CollabDays Hamburg 2025
Talbott Crowell
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PDF
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PPTX
Role_of_Artificial_Intelligence_in_Livestock_Extension_Services.pptx
DrRajdeepMadavi
 
PDF
NASA A Researcher’s Guide to International Space Station : Earth Observations
Dr. PANKAJ DHUSSA
 
PDF
Linux schedulers for fun and profit with SchedKit
Alessio Biancalana
 
PDF
Software Development Company Keene Systems, Inc (1).pdf
Custom Software Development Company | Keene Systems, Inc.
 
PPTX
Essential Content-centric Plugins for your Website
Laura Byrne
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
NASA A Researcher’s Guide to International Space Station : Fundamental Physics
Dr. PANKAJ DHUSSA
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Talbott's brief History of Computers for CollabDays Hamburg 2025
Talbott Crowell
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Role_of_Artificial_Intelligence_in_Livestock_Extension_Services.pptx
DrRajdeepMadavi
 
NASA A Researcher’s Guide to International Space Station : Earth Observations
Dr. PANKAJ DHUSSA
 
Linux schedulers for fun and profit with SchedKit
Alessio Biancalana
 
Software Development Company Keene Systems, Inc (1).pdf
Custom Software Development Company | Keene Systems, Inc.
 
Essential Content-centric Plugins for your Website
Laura Byrne
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
NASA A Researcher’s Guide to International Space Station : Fundamental Physics
Dr. PANKAJ DHUSSA
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Ad

Unobtrusive javascript

  • 2. ïŹ JavaScript guru Douglas Crockford calls the browser “the most hostile programming environment in the world.” ïŹ He said this before mobile browsing was even a thing at which point he said: ïŹ “I used to say that the web browser was the most hostile programming environment ever devised, but that was before I found out about Mobile.” ïŹ Infinite combinations of hardware and software The front end stack
  • 3. HTML ïŹ HTML is forgiving and browsers can deal with invalid markup ïŹ Markup that doesn't meet the spec will still give you a mostly working page
  • 4. CSS ïŹ CSS is aloof. If it encounters something it doesn't understand, it just shrugs and moves on ïŹ Some IE CSS hacks take advantage of CSS quirks (It's not a bug, it's a feature)
  • 5. Javascript ïŹ Javascript is a quitter. If it encounters a problem it just gives up and goes on strike. ïŹ Some browsers may ignore your script completely ïŹ Even when a browser can support JavaScript, users may turn it off for security reasons, or their corporate firewall may block it ïŹ Even when a browser supports JavaScript, it may not understand parts of your script because it has a proprietary implementation of some parts of the DOM specification (usually IE) ïŹ Even when the script is interpreted correctly, it may depend on HTML that is very complicated and/or might change in unpredictable ways.
  • 6. A lesson from history
  • 7. First world problems ïŹ Last February the download button for google chrome broke. ïŹ Nobody could download chrome for 12 hours ïŹ It was caused by a javascript error ïŹ This was an easy problem to avoid
  • 8. What went wrong? ïŹ Somebody broke an unrelated javascript library used by the google chrome website and included in all pages ïŹ Uncaught TypeError: Cannot read property 'value' of undefined ïŹ Because google did not include a href, the browser could do nothing except sit there looking embarrassed
  • 10. What google did wrong ïŹ Didn't follow the rules of unobtrusive javascript ïŹ Created a single point of failure ïŹ Ignored web standards ïŹ Trusted core functionality to the most fragile part of the front end stack
  • 11. Why do you hate javascript? ïŹ Javascript is great ïŹ But don't start with it ïŹ It's like building a house by choosing the wallpaper first ïŹ The purpose of JavaScript is to add a layer of usability to your site. If the script is the entire usability layer (in other words, if the site is unusable without JavaScript), your javascript is not unobtrusive.
  • 12. Principles of unobtrusive javascript ïŹ Your site should work without JavaScript. ïŹ If JavaScript happens to be enabled, you can present your users with an extra layer of usability; a layer that allows them to perform their tasks more quickly, and that avoids jarring page reloads where possible. ïŹ JavaScript is unsafe. That is, you should *never* trust in JavaScript-only routines for crucial tasks such as checking user input in a form.
  • 13. p.s. Google still don't have a href on that link. Maybe they invested in better functional tests instead?