How to Create a JavaScript Object With a Dynamic Property

If you want an object obj with a property of hello and a value of world, you can do this:

const obj = {
  hello: 'world';

If the property name hello is determined elsewhere, you can do this:

// Pretend this 'hello' gets determined abroad
const propName = 'hello';

const obj = {};
obj[propName] = 'world';

This is a bit verbose, however. A more succinct way is this:

const propName = 'hello';
const obj = {
  [propName]: 'world'

It seems simple enough, but I only recently grasped that this syntax is possible. You might think that reducing two statements into one isn’t that much of a gain, but it becomes incredibly useful with CSS Modules in Vue:

<p :class="{ [$]: isRed }">
  Am I red?

This class expression wouldn’t be possible without this feature.

The Best Laptop Ever Made  

Marco Arment:

Apple has made many great laptops, but the 15-inch Retina MacBook Pro (2012–2015) is the epitome of usefulness, elegance, practicality, and power for an overall package that still hasn’t been (and may never be) surpassed.

This piece really resonates. I’ve used this computer as my primary workstation for 25 months and it’s still going strong. Some day I will have to buy its replacment, but Apple has yet to ship a laptop that is its superior.

Zwift Raises Its Monthly Subscription to $14.99  

Eric Min, CEO:

From a scrappy little team that could all fit around a table and share a meal, Zwift’s staff has grown to over a hundred people including programmers, artists, designers, testers, community managers, coaches, marketers, and an awesome support staff working to help Zwifters when they have questions.

In order to continue to make Zwift bigger, better and more beautiful, we are updating our membership price to $14.99 per month, effective today. As a way of saying thank you, however, to the awesome Zwifters who helped us get here, your pricing will not change for one year.

There’s nothing like Zwift. It’s one of my favorite pieces of software. I ride outdoors in the summer, but during rainy days and in the cold of winter, Zwift is where it’s at. I knew the company was growing but I had no idea that there are now more than a hundred people at it. That’s fantastic.

This price increase might be a slight barrier to new customers, but I can’t imagine that anyone who’s experienced Zwift will mind the jump when it happens. Grandfathering the old pricing to preexisting customers for a year isn’t something the company had to do, but it’s a nice touch.1

  1. Far better to reward preexisting customers than to offer signup incentives for which your loyal base isn’t eligible. ↩︎

GitHub Introduces Teletype for Atom  

From the GitHub blog:

Writing code with other developers can be a great way to onboard teammates, get to know how your peers think, and learn new skills. Unfortunately, writing code together can be difficult to coordinate.

Now social coding is easier than ever with Teletype for Atom—a new way to dive right into code with remote collaborators. Work together in real time with your own configurations in your own programming environment on any file you can open in Atom.

I hear BBEdit is going to get this any day now.

Ditch jQuery

After stewing over Alex Russell’s performance budget for some time, I reduced my JavaScript footprint last night from 105KB to 18KB by removing jQuery as a dependency.1 I rewrote my use of jQuery into pure JavaScript. As a result, the site loads faster — consistently under 100ms — with zero setbacks to the user experience.

jQuery has been called a “find something do something” library, and that’s an accurate description for it. It is not a robust library for reactively perculating state changes through a UI. If you want that, you’ll use VueJS or React or Angular. Since those libraries are heavier than my simple frontend needs at this site however, I chose to just go with pure JavaScript.

When jQuery was first released in August 2006, it solved a real need, because these aforementioned frameworks didn’t exist and native JavaScript was bad at “find something do something.” Eleven years later, that’s changed. jQuery is redundant. The native abilities in JavaScript to fetch DOM objects by class name, to manipulate those classes, and to transverse up and down the DOM from a specific object, are all only slightly more verbose than their jQuery equivalents.

Sure, it’s still a wee faster writing jQuery than pure JavaScript, but hardly for someone well-versed in the native abilities of JavaScript, and whatever miniscule time savings jQuery affords is not worth the additional 82-87KB in file size that results in its use.

For the more curious, here’s a gist of the pure JavaScript for Drinking Caffeine.

  1. Of that 18KB, 16KB of it is for PrismJS syntax highlighting. If I were fine doing without that, my JavaScript would be a mere 2KB. ↩︎

Javascript Spread Operator in Object Literals Available in Chrome but Not Safari  

Here’s another reason Chrome is better than Safari: because it adapts new JavaScript specifications faster.1 As of Chrome 60, which was released July 25 of this year, you can use the spread operator in object literals. If you pop open your browser console, this will work in Chrome but not Safari.

const user = { firstName: 'Martyn' }
const clonedUser = { ... user }

In Safari, you get this error:

SyntaxError: Unexpected token ‘…’. Expected a property name.

No, hey, sweetie, no.

  1. If you’re the sort of person who thinks this is a mute point because JavaScript shouldn’t be able to run in a browser in the first place, I have nothing to say to you other than that I hope you’re enjoying the weather in Philly. ↩︎

“Don't Muck My Markup” Update for PHP 7  

I’ve udated my one and only public WordPress plugin to be compatible with PHP 7. From the release notes from today’s update:

PHP 4 style constructors (methods that have the same name as the class they are defined in) are deprecated in PHP 7, and this update fixes the warning about this that you get when you’ve set define('WP_DEBUG', true); in your wp-config.php file.

This plugin is used on 3,000 active installs. That’s not a ton, but it’s enough that it’s a privilege to maintain. It solves a true pain point for folks.

How to Become a Better Writer  

In his new book Win Bigly, Scott Adams references this article he wrote back in 2007 on how to become a better writer. It’s short and lovely. Read it.

GitHub Introduces a Community Forum  

Barbara Kozlowski, writing at the GitHub blog:

The open source community proves that when creative people get together on an open platform, great things happen: Code gets better, new technologies emerge, and the way we build software changes. Now there’s a new way to connect with developers around the world. Join the GitHub Community Forum to ask questions, swap stories, and share ideas, regardless of whether you work on public or private projects.

Shots fired. is a direct competitor to Stack Overflow.

Sadly, this new venture doesn’t hold to the same impeccable design standards as the main GitHub website. It just isn’t as tight. Even more sadly perhaps, it’s still using the arcane DOM choice of HTML tables. Of course, HTML tables don’t play well on mobile, so the site is overriding the table functionality in its mobile CSS. There’s no need for any of this nonesense. There’s nothing you can do in an HTML table that you can’t do with CSS and flexbox.

I can’t use in its current state, I’m afraid. I hope it becomes a first class citizen, because I would love to see it give long-in-the-tooth Stack Overflow a run for its money.1

  1. I love SO’s content, but there’s zero UI/UX innovation happening in mainstream technical QA community software. ↩︎

Ben Thompson on the Senate Hearing With Google, Facebook, and Twitter  


I still believe that, on balance, blaming tech companies for the last election is, more than anything, a convenient way to avoid larger questions about what drove the outcome. And, as I noted, the fact is that tech companies remain popular with the broader public.

Everything about this piece is gold: the video clips of the hearing, the analysis, the nonpartisan dissection — everything. But this paragraph especially made my day.

Why Angular 4 Skipped Version 3  

Juri Strumpflohner:

Due to this misalignment of the router package’s version, the team decided to go straight for Angular v4. In this way again, all the core packages are aligned which will be easier to maintain and help avoid confusion in the future.

So, due to one sub-package that got a little out of control, the entire Angular project jumped to v4. This news is literally 10 months old but it’s hilarious to me, seeing it for the first time. I’ve been out of the Angular loop I guess. Bless them.

VueConf 2018  

I’m excited to be attending VueConf in New Orleans, March 27-28, 2018. It’s the first VueJs conference to occur on US soil (last year’s was the framework’s first, and it occurred in Poland). VueJS is mostly what I write these days, so it should be a solid event. I’ll likely post a stream of notes here during the keynotes. If you’re able to make it, I’d love to say hi.

Alex Russell on Web Performance Budgets  

Alex Russell:

A lot of progress is Darwinian and for startups and small teams, betting on the wrong stack without the benefit of a long runway can be fatal. Worse, this can go un-diagnosed for a long, long time. If the whole team carries the latest iOS devices on fast, urban networks and the product’s economics are premised on growing a broad-based audience, the failure of that audience to arrive barely makes a sound.

This must-read piece makes a resoundingly compelling argument to keep your initial JavaScript footprint at 130-170KB. Drinking Caffeine, which uses almost no JavaScript but just enough to use jQuery, comes in at a total of 105KB minified. For a text-only site that’s astounding; I’ve nearly maxed my Javascript budget, simply because I use jQuery.

Gmail Snooze with Apps Script  

If you live in Google Inbox, there’s a handy snooze feature that you get out of the box. If you’re like me and prefer using third party apps to handle your mail, this feature isn’t availble. What there is instead is a script that you can run that will do this for you. I implemented this yesterday and it’s working like a charm.

As an example, if I wanted to automatically snooze for 1 day all emails that had a subject of “Hello world,” I’d create a filter with this search:

has:nouserlabels subject:(Hello world)

And then I would select “Apply the label:” and choose “Snooze/Snooze 1 days,” as auto-generated from that Apps script. I would also checkmark “Skip the Inbox (Archive it).” The result is that throughout the day, any emails that contain “Hello world” in the subject would not appear in my inbox until midnight each night, at which time they would all appear at once.

It’s a fantastic way to reduce the distraction and noise of email while still receiving everything.

Why Some Customers Can Order the iPhone X Faster Than Others  

Killian Bell, writing at Cult of Mac:

It is believed Apple will have just 2-3 million iPhone X units available at launch, which is why initial supplies will have sold out so quickly. That doesn’t explain why some customers could pre-order before others, however.

I have an explanation why some customers can pre-order before others: it’s because the website works for some people before it works for others, which means that the perculation of the deploy reaches some people faster than others. The Internet isn’t like TV, where you either catch the signal or you don’t. The Internet is distributed. There isn’t one single server that’s “the Apple website.” Rather, there are many servers, and depending on a lot of factors, some people are going to get access to those servers sooner than others are. Deploying a set of changes to a website in such a way that those changes perculate to everyone in the world at the exact same time is an incredibly difficult problem to solve. Most deploys are staged, and that’s usually not a problem; this situation with the iPhone launch is one of the few exceptions I can think of.

Here’s the part that nobody ever talks about. Even if Apple could solve this problem perfectly, it would still have the problem of people having to wait 2-3 weeks out. If people could access the site at exactly 12:01 AM PDT and place their order immediately, the number of people who would have to wait multiple weeks to get their iPhone X’s would be the exact same.1 Instant perculation wouldn’t change the number of customers nor the number of available iPhone X’s. This isn’t a technological problem. This is a supply contraint problem, and that’s a testimony to the success of the iPhone X. Calling that “a complete nightmare” as Killian does is not a fair description of what transpired last night.

  1. A tempting retort to this proposition is this: “Sure, the number of people would be the same, but it would be a different set of people. Why should I be the one punshed (by having to wait 2-3 weeks for my iPhone X) when I got up just as early as the customer who successfully completed their order right at 12:01 AM?” My answer is this: if we were to get everyone in a room together who got up at midnight to pre-order the iPhone X and gave them a button to tap as soon as an overhead light turned green, there would still be people who had to wait 2-3 weeks. With a couple million people in the room, speed wouldn’t really be the determining factor. You’d have thousands of people who pressed the button at the exact same millisecond. The system would be forced to prioritize some orders ahead of other orders based on what to the outside appeared to be arbitrary assortment. The orders that were successfully placed before yours would be by by people who were just as eager and just as fast with the trigger as you. In short, if you’re frustrated with your ordering experience, be frustrated with your lost 9 minutes of sleep that you would’ve enjoyed if Apple had a perfect deploy system and servers that could process orders faster. Having to wait 2-3 weeks is not Apple’s fault. It’s a necessarily emergent property of this sort of product launch and supply constraint, as demonstrated in my thought experiment. Frustration with necessarily emergent properties is a poor use of energy. ↩︎

Actually, Increasing the VIP Limit Will Come With a Performance Cost  

I get triggered when someone thinks that they are smarter and know more about someone’s code than the person who wrote the code, when they themselves haven’t even seen the code, nor understand the challenges that presented themselves at the time. I expect this from the tech journalists with English degrees who understanding little about the inner workings of computers and how software works. I do not expect this, however, from people with computer science degrees, which is why I was disappointed to hear John Gruber postulate confidently that increasing the VIP limit in iCloud mail from 100 to 500 would pose zero problems from a technological standpoint. We have no idea if it would or not, but using our degrees we can make a pretty educated guess, and the result of that guess is that it absolutely would come with a perf cost.

I have no idea how Apple’s VIP system works, but if I were building it, I’d have an array, probably coming from a database, of all the VIP email addresses. When determining whether to notify about an email or not, I’d check the email address in question against that array, to see if it exists in that array or not. Searching an array gets more expensive the larger your array is. This is basic computer science. I can’t say to what extent increasing the limit to 500 would be a performance cost, but make no mistake — it would absolutely be benchmarkable.

If this computation were happening on Apple’s servers, and I don’t know why it wouldn’t be, then a software change like this one will be amplified by scale. If we’re talking a few milliseconds on a single email, multiply that by every single email of every person who uses this feature. Soon you’re potentially looking at minutes of daily server time spent on accommodating the increase of the VIP list from 100 to 500.

A New Dark Theme  

This week I threw together a dark theme for Drinking Caffeine. You’ll never guess where I got my inspiration for its design. Check it out. I haven’t made it the default, but it’s definitely my personal setting. Tell me what you think of it!

Screenhero Is Now in Slack  

From the Screenhero home page:

If you currently use Screenhero, you’ll need to migrate your team to Slack before December 1st, 2017. At that point, the stand-alone Screenhero app will no longer work — but you can enjoy the same features in Slack.

The goal of Slack’s acquisition of Screenhero was to integrate it seamlessly into Slack. We’re just 5 weeks out from that being fully realized.

In Defense of Douglas Crockford  

Nodevember is a little more than a month away and some of us were considering going to it. Then we read its announcement from Twitter that it was going to cancel Douglas as a speaker from last year’s conference because he used the words weak and promiscuous. That leaves a bad taste in my mouth. If the whole conference is comprised of people who are this touchy, it’d be a very laborious two days.

Meanwhile though, this piece by Adam Morgan is excellent.

GitHub Favicons Now Indicate PR Status  

It’s a small change, but it makes the day-to-day workflow that much nicer. The past two of years I’ve been averaging about 600 merged pull requests per year, and the overwhelming majority of them have continuous integration running on them. This means that switching to a PR tab to see whether it’s green yet or not has been a daily workflow. GitHub just made that workflow a lot easier. Now all I have to do is just look at the tab’s favicon.1

  1. Oh yeah—and that’s yet another reason to not use Safari as a browser, since it doesn’t have the ability to show favicons. Silly Safari. 🙃 ↩︎

The Receding Tide  

Seth Clifford:

But the fact of the matter is that I’ve lost whatever thing inside me made me want to write and put it somewhere, and I’m not sure why. I’ve lost the desire to do pretty much anything on the internet in any public capacity, and part of it is just who I am at the moment, and part of it is my ever-growing disenchantment with the rest of the world at the current time. So I’ve decided to just become an NPC for the time being. Background scenery. Foliage.

I’m just not interested in being someone on the internet anymore.

I’m not yet as far down this path as Seth is, but this whole piece really resonates with me.

“That’s Not Why There’s a Notch”  

Jason Baroni:

They could’ve wiped out the notch, but in 2 years it would look like anyone else’s phone. It’s there to be a distinguishable, iconic design.

In saying this, Jason is parrotting Marco’s bizarre thoughts on this, in which he said:

This is the new shape of the iPhone. As long as the notch is clearly present and of approximately these proportions, it’s unique, simple, and recognizable.

It’s probably not going to significantly change for a long time, and Apple needs to make sure that the entire world recognizes it as well as we could recognize previous iPhones.

Here’s John Gruber’s response to this idea:

That’s not why there’s a notch.

It always bothers me when people outside of Apple postulate that they have great wisdom and insight into the secret will of Apple. I find that usually they’re wrong. Until there’s hard evidence, I don’t believe this notch is about “courage” or “iconic design.” It’s there for one reason only: because with current technological constraints, it has to be there. If Apple could have built the iPhone X without the notch, it would have done so. If and when the day comes that Apple can build the iPhone X without the notch, it will do so.

Strava Enables Posts for All Users  

From the Strava blog:

Strava has long been the place to record your activities, but there’s a lot more to being an athlete than working out. Stories, photos, questions, gear tips, route recommendations, activity invites – starting today, you can share more of your athletic life with posts.

With this new functionality, we’re redesigning the feed so that it’s easier to see what’s going on in your athletic world. Activities remain at the heart of the new feed, with photos, maps and achievements more prominently displayed so your efforts get the attention they deserve.

Your activities and achievements stand out in the new feed.

I’m not happy about this feature. Strava isn’t a social network. It’s not about sharing ideas. It’s about tracking your athletic activities and those of your friends. If I see a Strava post from someone in my feed, I will unfollow them. No offense. I just refuse to allow this sort of nonsense in my home feed.

Face ID and Racial Bias  

Asem Othman, writing for The Next Web:

One more error metric that Apple did report is the rate of the system rejecting your selfie and requesting one more capture although you are the genuine owner of the phone. So, most probably, this error (False Rejection error) also will vary based on the population that are using the phone. In other words, some population/race will get more rejections and more requests to recapture their selfies

Yeah, let’s just go ahead and assume that Apple baked racism into Face ID. The company “most probably” did.

I hope Asem isn’t too disappointed if he’s proven wrong and Face ID actually works for people in China.