Wednesday is Link Day

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

Performance

Performance Testing Dictionary, a free book (registration required): http://info.soasta.com/PerformanceTestingDictionary.html

Yes, a performance budget builder: http://bradfrost.com/blog/post/performance-budget-builder/

Measuring performance (using the navigation timing API): https://davidwalsh.name/measuring-performance

Aligning app performance to business success (podcast): http://www.thecloudcast.net/2016/01/the-cloudcast-236-aligning-app.html?m=1

Performance advice from experts: https://www.keycdn.com/blog/web-performance-advice/

A good case study on performance improving the bottom line: http://www.soasta.com/blog/mobile-web-performance-monitoring-conversion-rate/

The “average page” is a myth: https://www.igvita.com/2016/01/12/the-average-page-is-a-myth/

Accessibility

This 1939 Chart Explains How Color Affects Legibility: http://www.fastcodesign.com/3052263/infographic-of-the-day/this-1939-chart-explains-how-color-affects-legibility

What’s coming up for Microsoft Edge in 2016. Number 2 on the list: Accessibility: https://blogs.windows.com/msedgedev/2016/02/03/2016-platform-priorities/

What to do when you get sued for your inaccessible website: http://www.karlgroves.com/2016/01/18/what-to-do-when-you-get-sued-revisited/

The BBC gives advice on how to design for accessibility: http://www.bbc.co.uk/gel/guidelines/how-to-design-for-accessibility

The business case for issue prevention: Extreme Accessibility: http://www.karlgroves.com/2016/01/10/the-business-case-for-issue-prevention-extreme-accessibility/

Accessibility for business and pleasure: https://www.paciellogroup.com/blog/2016/01/accessibility-for-business-and-pleasure/

The browser accessibility tree: https://www.paciellogroup.com/blog/2015/01/the-browser-accessibility-tree/

Progressive Enhancement

A simple enhancement for ordering items by, who else, Jeremy “My Man Crush” Keith: https://adactio.com/journal/10195

“JavaScript web apps considered valuable”: http://molily.de/javascript-web-apps/

“Why I hate your single page app”: https://medium.com/@stilkov/why-i-hate-your-single-page-app-f08bb4ff9134#.foqjt3t2x

“Don’t tell me what my browser can’t do”: https://medium.com/@codepo8/don-t-tell-me-what-my-browser-can-t-do-b95ab0d3cacd#.13211xmd5

Progressive web apps by Google (I may have linked to this before): https://developers.google.com/web/progressive-web-apps

Mobile

Mobile and Multi-device design: a free e-book (on Apple devices only, bah): https://itunes.apple.com/us/book/mobile-multi-device-design/id916423134?mt=11

The world’s poorest households are more likely to have a mobile phone than a toilet: http://qz.com/594455/the-worlds-poorest-households-are-more-likely-to-have-a-mobile-phone-than-a-toilet/

As mobile screen size increases, so does activity: http://www.lukew.com/ff/entry.asp?1956

Launch an Android app from the web and cleanly fallback to web: https://paul.kinlan.me/launch-app-from-web-with-fallback/

Development

Shared before, but still great. Offline access to documentation: http://devdocs.io/

Give developers autonomy. Couldn’t agree more: http://mikehadlow.blogspot.co.il/2014/06/heisenberg-developers.html

Want to write software for your car? It’s coming: https://www.w3.org/2014/automotive/vehicle_spec.html

The history of Open Source, and a glimpse at its future: https://medium.com/@nayafia/we-re-in-a-brave-new-post-open-source-world-56ef46d152a3#.hn8q4llo1

The woes of date input (yep, got that t-shirt): http://html5doctor.com/the-woes-of-date-input/

“Paid a great deal to be terrible at development most of the time”: https://www.exratione.com/2016/01/paid-a-great-deal-to-be-terrible-at-development-most-of-the-time/

The art of debugging (presentation and video): https://remysharp.com/2015/10/14/the-art-of-debugging

Martin Fowler on feature toggles: http://martinfowler.com/articles/feature-toggles.html

Control CSS filters with HTML attributes: http://specro.github.io/Philter/

Developer fallacies: https://medium.com/@Heydon/developer-fallacies-70a381fb493c#.ojg3yezas

The sad state of entitled web developers: https://medium.com/swlh/the-sad-state-of-entitled-web-developers-e4f314764dd#.n6ps2t69q

Most developers have never seen a successful project: http://www.theregister.co.uk/2015/11/11/most_developers_never_seen_successful_project/?mt=1452522136493

Testing

Via Beth: what’s next for manual testers: https://www.utest.com/articles/the-present-and-future-of-manual-testing

On screen reader testing: http://clearleft.com/thinks/362

Design/CSS/UX

“Design without touching the surface”: http://leapfrog.nl/blog/archives/2016/02/07/design-without-touching-the-surface/

Great talk by Jen Simmons about getting out of our design rut: https://www.youtube.com/watch?v=ZNpn7FBp_9U

CSS best practices presentation: http://fantasai.inkedblade.net/style/talks/best-practices/

The Goldilocks approach to responsive design: http://goldilocksapproach.com/

About notifications and no-UI: https://www.rehabstudio.com/thinking/losing-our-heads/

The dangerous UI team: http://blog.ometer.com/2016/01/26/the-dangerous-ui-team/

JavaScript

We need to really understand promises: http://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html

Offline with ServiceWorkers and UpUp: https://dev.opera.com/articles/offline-with-upup-service-workers/

2016 – the year of streams: https://jakearchibald.com/2016/streams-ftw/

Definitive guide on charts in JavaScript: http://www.fusioncharts.com/javascript-charts-guide/

const and immutable objects in ES6: https://ada.is/blog/2015/07/13/immutable/

Regex in JavaScript made easy: https://github.com/VerbalExpressions/JSVerbalExpressions

Resources

Old-school PC fonts: http://int10h.org/oldschool-pc-fonts/fontlist/

Online regular expression tester: https://regex101.com/

Stupid hackathon. Featuring my favourite Chrome extension “Non-Ad Block”: http://www.stupidhackathon.com/

A feature detection library in 1KB: http://featurejs.com/

Images and sketches of popular mobile devices (from Facebook): https://facebook.github.io/design/devices.html

And finally…

Remember Command and Conquer? Here it is in HTML5: http://www.adityaravishankar.com/projects/games/command-and-conquer/

A briefish history of the web (in 3 parts): https://briankardell.wordpress.com/2015/11/22/a-briefish-history-of-the-web-universe-part-i-the-pre-web/

Play a drum machine with your keyboard. And record it. Yes: http://sampulator.com/

And if that wasn’t good enough, here’s a TR-808: http://codepen.io/pixelass/full/adyLPR

Free philosophy e-books. Cos I know you love ’em: http://www.openculture.com/free-philosophy-ebooks

What Tor’s data looks like as it flows around the world: http://www.wired.com/2016/01/heres-what-tors-data-looks-like-as-it-flows-around-the-world/

The web is OK: http://www.charlotteis.co.uk/the-web-is-okay/

Tuesday is Link Day!

Performance

Presentation on “Smaller, faster websites” by Mat Marquis: https://bocoup.com/weblog/smaller-faster-websites

The website obesity crisis (presentation): http://idlewords.com/talks/website_obesity.htm

What developers should know about performance: https://medium.com/@christophelimpalair/developers-what-you-should-know-about-web-performance-550cef1040d8

What I’ve learned from monitoring four years of web page bloat: http://www.soasta.com/blog/page-bloat-2015-web-performance-monitoring/

Articles about how web performance affects revenue: https://wpostats.com/tags/revenue/

Avoiding Temptations that Harm Website Performance: http://calendar.perfplanet.com/2015/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.” https://adactio.com/journal/9963

What “progressive web apps” mean for the web: http://developer.telerik.com/featured/what-progressive-web-apps-mean-for-the-web/

Interaction is an enhancement – an excerpt from Aaron Gustafson’s new book: http://alistapart.com/article/interaction-is-an-enhancement

The article that first described progressive enhancement: http://hesketh.com/progressive_enhancement_and_the_future_of_web_design.html

Reimagining Single-Page Applications With Progressive Enhancement: http://www.smashingmagazine.com/2015/12/reimagining-single-page-applications-progressive-enhancement/

Accessibility

The modern web is broken for people with disabilities: https://www.thoughtworks.com/insights/blog/modern-web-fundamentally-broken-people-disabilities

Mozilla accessibility QA engineer tells us what the basics of accessibility are: https://www.marcozehe.de/2015/12/14/the-web-accessibility-basics/

Learn about accessibility in just 20 minutes: http://accessibility.parseapp.com/

On accessibility and the lack of proper HTML: http://www.iandevlin.com/blog/2016/01/opinion/on-accessibility-and-the-lack-of-proper-html

Free web accessibility tools round-up: https://medium.com/bread-crumbs/free-web-accessibility-tools-round-up-b83a33797789

Mobile

Why you shouldn’t bother creating a mobile app: https://medium.com/inside-birdly/why-you-shouldn-t-bother-creating-a-mobile-app-328af62fe0e5

The App-ocalypse: Can Web standards make mobile apps obsolete?: http://arstechnica.com/information-technology/2015/12/the-app-ocalypse-can-web-standards-make-mobile-apps-obsolete/

Instant Loading Web Apps with An Application Shell Architecture: https://developers.google.com/web/updates/2015/11/app-shell

Design/UX

Dark Patterns: fighting user deception worldwide: http://darkpatterns.org/

A rant: how are website still screwing up these user experiences: http://www.troyhunt.com/2016/01/its-2016-already-how-are-websites-still.html

Simple inline error message pattern: https://www.paciellogroup.com/blog/2016/01/simple-inline-error-message-pattern/

Three principles for using design successfully. No 1: Start with design, and don’t just end with it: http://blogs.wsj.com/accelerators/2014/02/21/john-maeda-three-principles-for-using-design-successfully/

Brad Frost is writing a book on Atomic Design, which you can read for free here: http://atomicdesign.bradfrost.com/

How to make sense of any mess, a free online book on information architecture: http://www.howtomakesenseofanymess.com/

Beyond the style guide: https://24ways.org/2015/beyond-the-style-guide/

How to do a UX review: https://24ways.org/2015/how-to-do-a-ux-review/

Business

Psychological pricing strategies (mammoth set of tactics!): http://www.nickkolenda.com/psychological-pricing-strategies/

The perfect storm in digital law: http://alistapart.com/article/the-perfect-storm-in-digital-law

What customer experience excellence looks like: “Customer experience is 10% technology and 90% culture”: http://www.gerrymcgovern.com/new-thinking/what-customer-experience-excellence-looks

Helping VIPs care about performance: https://24ways.org/2015/helping-vips-care-about-performance/

Teams/general development

Rachel Andrew on confidence and getting overwhelmed: https://medium.com/@rachelandrew/web-industry-confidence-and-overwhelm-e161313405c8

What RESTful actually means: https://codewords.recurse.com/issues/five/what-restful-actually-means

What do we ask in Stack Overflow: http://jkunst.com/r/what-do-we-ask-in-stackoverflow/

Yahoo gets rid of QA: http://spectrum.ieee.org/view-from-the-valley/computing/software/yahoos-engineers-move-to-coding-without-a-net

JavaScript

A useful JavaScript glossary: https://github.com/HugoGiraudel/SJSJ

Microsoft open sourcing the Chakra JavaScript engine: https://blogs.windows.com/msedgedev/2015/12/05/open-source-chakra-core/

An “operating system”, with lots of apps, in JS: http://os.js.org/

“Every JavaScript project you should be looking into”: http://www.javascriptoo.com/

Amiga emulator in JavaScript, with games: http://scriptedamigaemulator.net/

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

You don’t need jQuery: https://github.com/oneuijs/You-Dont-Need-jQuery

4 JavaScript design patterns you should know: https://scotch.io/bar-talk/4-javascript-design-patterns-you-should-know

Use React? here’s a cheat sheet: http://reactcheatsheet.com/

CSS

Flexbox Froggy – learn flexbox with a fun game: http://flexboxfroggy.com/

Flexbox support is pretty good, except for IE: http://caniuse.com/#feat=flexbox

And there’s now an IE 8/9 polyfill: https://github.com/10up/flexibility

Web components that can be built purely using css, NO Javascript: http://technical.nailfashionsweden.se/web-components-that-can-be-built-purely-using-css-no-javascript/

“Just add water” CSS animations: https://daneden.github.io/animate.css/

Tools and resources

Security Panel debuts in Chrome DevTools: https://developers.google.com/web/updates/2015/12/security-panel

Dictionaries and Word Lists for Programmers: http://organicdonut.com/2015/12/dictionaries-and-word-lists-for-programmers/

Some good videos to watch, mostly JavaScript: http://fettblog.eu/top-talks-to-watch-2015/

Big list of “free for development” services: https://github.com/ripienaar/free-for-dev

Use console.table for easier logging: https://umaar.com/dev-tips/82-console-table/

SpaceHolder – A space-themed image placeholder service: https://spaceholder.cc/

How to use Chrome DevTools like a Pro: https://medium.com/jotform-form-builder/how-to-use-chrome-devtools-like-a-pro-b9bd414870e3

Each year this online advent calendar has fantastic articles: https://24ways.org

And so does this performance-specific advent calendar: http://calendar.perfplanet.com/

And finally

History of the web: http://www.w3.org/2012/08/history-of-the-web/origins.htm

See websites in old – I mean REALLY old – browsers: http://oldweb.today/WWW/20151225064327/http://info.cern.ch/hypertext/WWW/TheProject.html

GCHQ going open source? https://github.com/GovernmentCommunicationsHeadquarters

zty.pe, a typing game: http://zty.pe/

For the geek in your life: Star Wars Kama Sutra: http://www.amazon.com/dp/1519483058/

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' => 'http://example.com/foo'
        ) );

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 ‘http://example.com/foo’. 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;
unset($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:
$wpdb->expects($this->once())->method('get_var')->will($this->returnValue(1);

// 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 WordPress.com 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:
no-js

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 wordpress.com/browsehappy 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 = 'https://wordpress.com/browsehappy?url=' + encodeURIComponent( window.location );
    }
})();

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

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):

all-resources

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
gravatar.com 7 Avatars
fonts.googleapis.com 5 Web font stylesheets
fonts.gstatic.com 11 Web fonts
wp.com 34 Stats collection, jQuery, stylesheets, favicons and widget HTML
wordpress.com 13 Stylesheets, main JavaScript files
google-analytics.com 2 Analytics tracking
olark.com 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.