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 →

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.