Wednesday is Link Day

It’s been a while, so here’s a humongous list of goodies for y’all.


Performance Testing Dictionary, a free book (registration required):

Yes, a performance budget builder:

Measuring performance (using the navigation timing API):

Aligning app performance to business success (podcast):

Performance advice from experts:

A good case study on performance improving the bottom line:

The “average page” is a myth:


This 1939 Chart Explains How Color Affects Legibility:

What’s coming up for Microsoft Edge in 2016. Number 2 on the list: Accessibility:

What to do when you get sued for your inaccessible website:

The BBC gives advice on how to design for accessibility:

The business case for issue prevention: Extreme Accessibility:

Accessibility for business and pleasure:

The browser accessibility tree:

Progressive Enhancement

A simple enhancement for ordering items by, who else, Jeremy “My Man Crush” Keith:

“JavaScript web apps considered valuable”:

“Why I hate your single page app”:

“Don’t tell me what my browser can’t do”:

Progressive web apps by Google (I may have linked to this before):


Mobile and Multi-device design: a free e-book (on Apple devices only, bah):

The world’s poorest households are more likely to have a mobile phone than a toilet:

As mobile screen size increases, so does activity:

Launch an Android app from the web and cleanly fallback to web:


Shared before, but still great. Offline access to documentation:

Give developers autonomy. Couldn’t agree more:

Want to write software for your car? It’s coming:

The history of Open Source, and a glimpse at its future:

The woes of date input (yep, got that t-shirt):

“Paid a great deal to be terrible at development most of the time”:

The art of debugging (presentation and video):

Martin Fowler on feature toggles:

Control CSS filters with HTML attributes:

Developer fallacies:

The sad state of entitled web developers:

Most developers have never seen a successful project:


Via Beth: what’s next for manual testers:

On screen reader testing:


“Design without touching the surface”:

Great talk by Jen Simmons about getting out of our design rut:

CSS best practices presentation:

The Goldilocks approach to responsive design:

About notifications and no-UI:

The dangerous UI team:


We need to really understand promises:

Offline with ServiceWorkers and UpUp:

2016 – the year of streams:

Definitive guide on charts in JavaScript:

const and immutable objects in ES6:

Regex in JavaScript made easy:


Old-school PC fonts:

Online regular expression tester:

Stupid hackathon. Featuring my favourite Chrome extension “Non-Ad Block”:

A feature detection library in 1KB:

Images and sketches of popular mobile devices (from Facebook):

And finally…

Remember Command and Conquer? Here it is in HTML5:

A briefish history of the web (in 3 parts):

Play a drum machine with your keyboard. And record it. Yes:

And if that wasn’t good enough, here’s a TR-808:

Free philosophy e-books. Cos I know you love ’em:

What Tor’s data looks like as it flows around the world:

The web is OK:

Tuesday is Link Day!


Presentation on “Smaller, faster websites” by Mat Marquis:

The website obesity crisis (presentation):

What developers should know about performance:

What I’ve learned from monitoring four years of web page bloat:

Articles about how web performance affects revenue:

Avoiding Temptations that Harm Website Performance:

Progressive enhancement

Jeremy Keith hits a million nails on the head: “Server-side rendering is not a fallback; client-side rendering is an enhancement.”

What “progressive web apps” mean for the web:

Interaction is an enhancement – an excerpt from Aaron Gustafson’s new book:

The article that first described progressive enhancement:

Reimagining Single-Page Applications With Progressive Enhancement:


The modern web is broken for people with disabilities:

Mozilla accessibility QA engineer tells us what the basics of accessibility are:

Learn about accessibility in just 20 minutes:

On accessibility and the lack of proper HTML:

Free web accessibility tools round-up:


Why you shouldn’t bother creating a mobile app:

The App-ocalypse: Can Web standards make mobile apps obsolete?:

Instant Loading Web Apps with An Application Shell Architecture:


Dark Patterns: fighting user deception worldwide:

A rant: how are website still screwing up these user experiences:

Simple inline error message pattern:

Three principles for using design successfully. No 1: Start with design, and don’t just end with it:

Brad Frost is writing a book on Atomic Design, which you can read for free here:

How to make sense of any mess, a free online book on information architecture:

Beyond the style guide:

How to do a UX review:


Psychological pricing strategies (mammoth set of tactics!):

The perfect storm in digital law:

What customer experience excellence looks like: “Customer experience is 10% technology and 90% culture”:

Helping VIPs care about performance:

Teams/general development

Rachel Andrew on confidence and getting overwhelmed:

What RESTful actually means:

What do we ask in Stack Overflow:

Yahoo gets rid of QA:


A useful JavaScript glossary:

Microsoft open sourcing the Chakra JavaScript engine:

An “operating system”, with lots of apps, in JS:

“Every JavaScript project you should be looking into”:

Amiga emulator in JavaScript, with games:

The service worker cookbook: “a collection of working, practical examples of using service workers in modern web apps”:

You don’t need jQuery:

4 JavaScript design patterns you should know:

Use React? here’s a cheat sheet:


Flexbox Froggy – learn flexbox with a fun game:

Flexbox support is pretty good, except for IE:

And there’s now an IE 8/9 polyfill:

Web components that can be built purely using css, NO Javascript:

“Just add water” CSS animations:

Tools and resources

Security Panel debuts in Chrome DevTools:

Dictionaries and Word Lists for Programmers:

Some good videos to watch, mostly JavaScript:

Big list of “free for development” services:

Use console.table for easier logging:

SpaceHolder – A space-themed image placeholder service:

How to use Chrome DevTools like a Pro:

Each year this online advent calendar has fantastic articles:

And so does this performance-specific advent calendar:

And finally

History of the web:

See websites in old – I mean REALLY old – browsers:

GCHQ going open source?, a typing game:

For the geek in your life: Star Wars Kama Sutra:

Unit testing in WordPress

One of the things I really appreciate about developing in the .Net stack is the fantastic unit test support. Using mocking libraries like moq and leaning on the power of nunit to handle my dependencies means I can write unit tests that truly do test just the unit under test. True unit tests are useful for three very important reasons:

  1. That the code is doing what it should
  2. That the code handles unexpected inputs correctly
  3. That after refactoring the code continues to do what it did before

A robust, extensive suite of tests – both unit and integration tests – are crucial for good quality software and, fortunately, have been pretty common in the .Net development world for a long while.

When developing for WordPress, however, it’s not always been that way. I remember not so many years ago that test of any kind wasn’t something often talked about in the WordPress community. I guess we were focussed on getting code shipped.

Things have changed, and automated testing is now a recognised part of the WordPress development workflow. One of the problems with the WordPress Unit Test Suite, as pointed out by Greg Boone, is that it’s not actually a suite of unit tests – it has dependencies like a MySQL database, so would be more correctly called a suite of integrations tests. Pippin also calls these kind of tests “unit”, but they are definitely integration tests.

I’m at risk of over-egging this point, so please read this good description of the difference between unit and integration tests.

To ensure the large WordPress plugin I’m currently building is as good as it can be I want to build a suite of (true) unit tests. That means I need way of mocking WordPress functions (such as do_action, apply_filters and wp_insert_post) and globals such as $current_user and – crucially – $wpdb. It turns out there are a few options, which I’ve briefly investigated. I’ll be using WP_Mock and the PHPUnit test double features.

The well-known WP_Mock from the clever guys at 10up is the backbone of mocking WordPress. It allows you to mock any WordPress function with some simple syntax:

\WP_Mock::wpFunction( 'get_permalink', array(
            'args' => 42,
            'times' => 1,
            'return' => ''
        ) );

This will mock the get_permalink method when the only argument is the integer 42, ensuring it is only called once, and returning the string ‘’. Clever stuff.

There are other static methods in the WP_Mock class which allow you to:

  • Mock a method which returns the same value (a pass-through method)
  • Mock the calling of filters and actions
  • Mock the setting of actions and filters

Mocking $wpdb turns out to be pretty simple, as I can use the built-in test double functionality in PHPUnit. Sample code in the MockPress project wiki shows I can do this:

// in my test setUp method:
global $wpdb;

// whenever I want to mock a $wpdb function I set up the method to mock:
$wpdb = $this->getMock('wpdb', array('get_var'));
// and set the value I want to be returned from my mock method:

// now I can check the mock returns what I want:
$result = $wpdb->get_var("select anything from anywhere");
$this->assertEquals(1, $result);

I now just have to ensure my code is written in such a way as to make unit testing easy! I can highly recommend The Art of Unit Testing by Roy Osherove if you want to get into this deeply.

WordPress Calypso

Recently Automattic have announced the release of Calypso, a next-generation interface to manage or Jetpack-enabled sites. It’s a very ambitious project, but I believe they have some of the best developers in the world. Plus Andy Peatling, who I’ve had a huge amount of respect for since he initiated the BuddyPress project, ran the team.

The interesting thing for developers is their choice of technology stack. Calypso is a single-page app, powered by Facebook’s React library, node.js, with data coming from the WordPress REST API. All mod cons, and the interface is certainly beautiful, easy to use and very fast.

But I have to admit I have concerns about single-page apps, and the “modern” approach of total reliance on JavaScript to power a UI. JavaScript is the least robust of the Holy Trinity of web technologies (HTML, CSS and JavaSscript) as it does not gracefully handle errors. Many sites fall into the trap of thinking they can rely on JavaScript when they can’t. CSS is in the same boat, although if you get *some* CSS then whatever you get will be used to style the page. If you get just *some* JavaScript the likelihood is that nothing will work. It’s clear that the only resource which we can really count on – and even then, it’s not 100% guaranteed – is the HTML.

So, using my favourite progressive enhancement testing tool (turning off JavaScript), what do you see in Calypso when javaScript fails? This:

Unfortunately there’s nothing there, just the WordPress logo. Perhaps showing the “unsupported” message by default would be better, as this is what the Calypso app redirects to if the browser doesn’t support some modern JavaScript APIs or is iOS version 5 or earlier.

Here’s the (JavaScript) code that checks whether the browser cuts the mustard, with comments from me:

(function() {
    function isSupported() {
        var ios, version, ua;
        ua = window.navigator.userAgent;
        // check if the browser supports window.history, which allows changing the displayed URL without refreshing the page
        if ( ! window.history ||
            ! window.history.pushState ||
            ! window.history.replaceState ||
            ! ( '__proto__' in Object.prototype )
        ) {
            return false;
        function getFirstMatch( regex ) {
            var match = ua.match( regex );
            return ( match && match.length > 1 && match[1] ) || '';
        ios = getFirstMatch( /(ipod|iphone|ipad)/i ).toLowerCase();
        version = getFirstMatch( /version\/(\d+(\.\d+)? )/i );
        // check if the browser looks like iOS version 5 or earlier
        if ( ios && version < 6 ) {
        // disable for now because it is breaking Chrome on iOS
        //return false;
        // if we get here we know we can run the app
        return true;
    if ( ! isSupported() ) {
        window.location = '' + encodeURIComponent( window.location );

And this is the “unsupported” message (with cute Nessie image):

OK, on to performance. As I’ve mentioned Calypso feels really fast. One of the principles for the project was speed, and it shows. It’s also responsive, which for a powerful “app” such as this is no mean feat.

The resource stats show that it’s pretty big, however (this is from Google Chrome dev tools for a new post edit page):


The breakdown of requests shows a large amount of JavaScript (as you’d expect) and quite a lot of CSS:

Resource type Requests Total filesize
All 93 1.9mb
HTML 1 2.2kb
CSS 22 322kb
JavaScript 17 1.4mb
Images 12 13.5kb
Fonts 17 137kb

I was surprised at the amount of web fonts, which led me to look at the dependencies on other domains. Here’s how that breaks down (again, this is for a edit post page):

Domain Requests Description 7 Avatars 5 Web font stylesheets 11 Web fonts 34 Stats collection, jQuery, stylesheets, favicons and widget HTML 13 Stylesheets, main JavaScript files 2 Analytics tracking 1 Chat facility, presumably for customer support

I ignored subdomains and XHR requests (which are the requests to the API to get data) for this table.

Better stats that don’t rely on me manually counting rows in dev tools could be got from WebPageTest, and I may do that when I figure out how to get WebPageTest to log in to Calypso.

My conclusion from this very quick investigation is that while Calypso is a very slick web app (whatever “web app may mean) its total reliance on JavaScript means it could easily break for users on low-powered devices or using it dodgy network conditions. If the aim of WordPress is to democratise publishing then this has to be for users is the worst of browsing scenarios as well as those of us lucky enough to have fast machines, modern browsers, and fast and stable networks.

My belief is that the WordPress team know this, and that work is already under way inside Automattic to enable things like server-side rendering and handling of POST requests. And, in the mean time, the classic admin interface is still available.

What this means for the huge plugin ecosystem will be very interesting to find out. That’s a topic for another post!

Crash Test Dummies

Crash test dummie reading "Crash Testing for Dummies"No, this isn’t a post about the band. It’s about real crash testing, also known as progressive enhancement testing.

Of course, this had to be Another Progressive Enhancement Post, didn’t it!

Ever thought about why car manufacturers test their cars under crash conditions? Is it because people deliberately drive their cars into walls or ditches? No; not usually, anyway. They test the safety of their cars because we live in an unpredictable world where things go wrong, all the time. Exceptional circumstances surround us every single day. Often we experience near misses – sometimes we’re no so lucky.

In fact, things go wrong on the roads so often that we’ve created thousands laws and guidelines that try to minimise the possibility of these exceptional circumstances occurring. We have speed limits and training before anyone can get behind the wheel of a car. We have street lighting and pedestrian crossings, kerbstones and crash barriers.

Yet things still go wrong on our roads. Sometimes through carelessness and stupidity, sometimes though negligence. Sometimes the blame can’t really be applied to anyone in particular.

Car manufacturers invest in making their cars safe, so that when the unexpected happens – which, at some point, it will – the occupants and other road users are kept as safe as possible. We expect nothing less, and safety features are rightly promoted to help sell cars. That’s good; we should strive to create a safer world where possible.

Yet on the web it’s a different story. No-one believes that things never go wrong online. In fact in my experience there’s rarely a web browsing session where something didn’t break. Images fail to load, sites respond so slowly they appear to be down, JavaScript throws an error because two scripts from different 3rd parties can’t co-exist, web fonts don’t load and so text is invisible. The list of what could – and often does – go wrong when loading websites goes on, and on, and on.

What’s happening here? Do we as web developers, designers, business owners not realise the inherent unpredictability of the Internet? Do we not understand that the web was designed to be like this – to keep going even if all that is delivered to the browser is the HTML? No, many of us understand but sweep this reality under the carpet.

We are dummies.

We’re dummies because we chase after the latest JavaScript framework-du-jour without considering if it supports the core principles of the web. We overload our pages with unoptimised images and gargantuan CSS files generated by a pre-processor. We fail to deliver first and foremost what our users fundamentally require – the content.

We’re dummies because we leave the crash testing to our users – the very people we should be protecting from those exceptional circumstances! And then we have the gall to complain that they aren’t using the latest browser or operating system, or that their device is underpowered. Here’s the reality for you: even when browsing conditions are optimal, things still often go wrong.

So, in my opinion are JavaScript frameworks bad? Do I detest CSS pre-processors? Do I have an allergy to beautiful imagery online? No, of course not. It’s our use of these tools which I rail against. Enhance your pages as mush as you want, but start from the beginning. Semantic HTML content and forms.

Don’t be a dummy.