Enhancing Optimistically

progressive-enhancement-101-6-638

Here’s how Filament Group enhances (or: used to) their website for browsers that “Cut the Mustard”:

if( "querySelector" in window.document && "addEventListener" in window ){
  // This is a capable browser, let's improve the UI further!
  window.document.documentElement.className += " enhanced";

  // load the enhanced scripting
  loadJS( "/path/to/enhancements.js" ); 
}

But what if a browser is “Cutting the Mustard”, but the connection (or a content blocker) is preventing the extra scripts from being loaded? Time to adjust the base logic, and build some fault tolerance into it.

Enhancing Optimistically →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.