Handling Failed HTTP Responses With fetch()

| Comments

Quiz: What does this call to the web’s new fetch() API do?

    .then(function() {
    }).catch(function() {

If you’re like me, you might assume this code logs “error” when run—but it actually logs “ok”.

This expectation probably comes from years of jQuery development, as jQuery’s ajax() method invokes its fail handler when the response contains a failed HTTP status code. For example, the code below logs “error” when run:

    .done(function() {
    }).fail(function() {

My Gif Creation Workflow

| Comments

I’m a big fan of embedding animated gifs in, like, everything. In my opinion, blog posts, tutorials, GitHub issues, tweets, and really, any online medium can occasionally stand to benefit from a quick gif.

I create a lot of these gifs, so I thought I’d share my routine for actually building these things, as I’ve tried several different workflows before ending up with something I like. The tl;dr is I work on a Mac; I use QuickTime to record my screen; and I use a little command-line script to convert the QuickTime-recorded .mov file into a .gif file. If that sounds interesting read on.

Mobile Safari's Performance is Not the Problem

| Comments

Earlier this week Nilay Patel of The Verge published an article about how “The Mobile Web Sucks”, which caught my attention, as I had written about the mobile web’s woes just a few days before.

But although both our articles argued that reading content on the mobile web can be less than ideal, our reasoning diverged when it came to explaining why. Whereas I argued that the issue is the web’s broken monetization and advertising model, Nilay argued that the issue is performance, and more specifically, “the performance of Mobile Safari”. Or in longer form:

“The entire point of the web was to democratize and simplify publishing using standards that anyone could build on, and it has been a raging, massively disruptive success for decades now. But the iPhone’s depressing combination of dominant mobile web marketshare and shitbox performance means we’re all sort of ready to throw that progress away.”

I don’t often take time out of my day to defend Safari, but in this case I feel the great need to take a few minutes to explain why Nilay’s argument is wrong, or at the very least off base.

NativeScript Quick Tip: Showing and Hiding Elements

| Comments

NativeScript supports the "collapsed" and "visible" states of the CSS visibility property. This means you can hide an element by setting its "visibility" property to "collapsed" in CSS. For example you can use the following CSS to hide all buttons.

button {
    visibility: collapsed;

Warning: Currently NativeScript is inconsistent with the CSS spec, as the CSS spec defines visibility: collapse, and NativeScript uses visiblity: collapsed. I have an issue open to resolve this discrepancy.

A reportValidity() Use Case and Polyfill

| Comments

Last week Chrome 40 was released, and while the greater web community was celebrating service workers landing, a little known DOM method made its first appearance in a browser: reportValidity().

Because I don’t think many people know what reportValidity() does, I thought I’d write a quick article about it. Personally I think the best way to explain reportValidity() is with a real-world example, so let’s start there.

Speed Up Your Cordova App with the WKWebView Plugin

| Comments

I woke up this morning to discover that the Telerik marketplace had a new WKWebView plugin:

I had written about the performance benefits of WKWebView before, and Eddy Verbruggen—the author of the WKWebView plugin—has done some performance benchmarks as well, so I knew the plugin would give a performance boost, but I had to see the benefits for myself.