Cutting the Mustard

When the BBC wrote about Cutting the Mustard in 2012, they did a great thing for web development. They developed a way to simplify web development that uses the principle of progressive enhancement. A great benefit of this technique, is you don’t have to need to create a bunch of extra code for cross-browser handling. Instead you get to write code the complies to the standard. The end result is that you end up with lighter code, that targets only the browsers that can handle it.

if('querySelector' in document
  && 'localStorage' in window
  && 'addEventListener' in window) {
    // bootstrap the javascript application
}

Jason Garber recently wrote an article revisiting the idea. He mentions “new mustard” referring to newer properties being tested. While it’s interesting to consider a few different properties to check, It feels a little odd to be too prescriptive about it. The properties being tested should be whatever properties you need for your application. If you need the Ambient Light API, it doesn’t make sense checking for the device pixel ratio, for example. If you only test for the code you are writing, your whole application will be more modular.

Sorry, but comments are closed. I hope you enjoyed the article