When to use CSS vs. JavaScript

This is a repost promoting content originally published elsewhere. See more things Dan's reposted.

CSS before JS #

My general rule of thumb is…

If something I want to do with JavaScript can be done with CSS instead, use CSS.

CSS parses and renders faster.

For things like animations, it more easily hooks into the browser’s refresh rate cycle to provide silky smooth animations (this can be done in JS, too, but CSS just makes it so damn easy).

And it fails gracefully.

A JavaScript error can bring all of the JS on a page to screeching halt. Mistype a CSS property or miss a semicolon? The browser just skips the property and moves on. Use an unsupported feature? Same thing.

This exactly! If you want progressive enhancement (and you should), performance, and the cleanest separation of behaviour and presentation, the pages you deliver to your users (regardless of what technology you use on your server) should consist of:

  • HTML, written in such a way that that they’re complete and comprehensible alone – from an information science perspective, your pages shouldn’t “need” any more than this (although it’s okay if they’re pretty ugly without any more)
  • CSS, adding design, theme, look-and-feel to your web page
  • Javascript, using progressive enhancement to add functionality in-the-browser (e.g. validation on the client-side in addition to the server side validation, for speed and ease of user experience) and, where absolutely necessary, to add functionality not possible any other way (e.g. if you’re looking to tap into the geolocation API, you’re going to need Javascript… but it’s still desirable to provide as much of the experience as possible without)

Developers failing to follow this principle is making the Web more fragile and harder to archive. It’s not hard to do things “right”: we just need to make sure that developers learn what “right” is and why it’s important.

Incidentally, I just some enhancements to the header of this site, including some CSS animations on the logo and menu (none of them necessary, but all useful) and some Javascript to help ensure that users of touch-capable devices have an easier time. Note that neither Javascript nor CSS are required to use this site; they just add value… just the way the Web ought to be (where possible).

Repost #11819

This is a repost promoting content originally published elsewhere. See more things Dan's reposted.

Disney's tweet: "#TheLionKing. 2019. ??"

Is it just me, or is this some fantastic fucking casting. For the first time perhaps ever, I feel confident that a remake of an already-good film has the potential to be awesome.

@RespectableLaw on North Sentinel Island

This is a repost promoting content originally published elsewhere. See more things Dan's reposted.

There’s been a lot of talk about the missionary killed by the natives of North Sentinel Island. They’re probably so aggressive because of this weirdo, Maurice Vidal Portman. So here’s a big thread about this creep and some facts from my decade-long obsession with the island.
The Sentinelese are often described as “uncontacted,” but this not strictly true. They had a very significant contact in 1880 with Commander Portman.
Portman, the black sheep third son of some minor noble, was assigned by the English Royal Navy to administer and pacify the Andaman Islands, a job he pursued from 1880-1900 with the full measure of his own perversity.
Portman was erotically obsessed with the Andamanese, and he indulged his passion for photography by kidnapping members of various tribes and posing them in mock-Greek homoerotic compositions.
During his 20 years in a sexualized heart of darkness, Portman measured and cataloged every inch of his prisoner’s bodies, with an obsessive focus on genitals.
Just imagine being a Neolithic person spending a few weeks in this guy’s rotating menagerie.
Portman spent most of his time in the greater Andaman Islands, but in 1880, he landed on North Sentinel. The natives fled, and his party ventured inland to find a settlement which had been abandoned in haste.
But they located an elderly couple and a few children they were able to abduct. The couple quickly died, likely from ailments to which they had no immunity.
The children spent a few weeks with Portman doing god knows what, after which he returned them to the island. Portman returned on a couple occasions, but the Sentinelese hid from him each time.
The story related by the children was certainly passed down among the 100 or so inhabitants of the island, and even today, Portman’s fatal kidnapping is just beyond a human lifetime.
So when the Indian government attempted contact with anthropologists in the 1960s and 70s, the Sentinelese were understandably hostile to outsiders. The Indian government soon gave up.
In 1981, a cargo ship named The Primrose ran aground on the coral reef surrounding North Sentinel. The crew radioed for assistance and settled in for a long wait. But in the morning they saw 50 men with bows on the beach, building makeshift boats.
The crew called for an emergency airlift and were evacuated, and not a moment too soon. Rough waves had thwarted the Sentinelese in their attempts to board, but the weather was clearing.
The ship and its cargo were left at the island, awaiting discovery by Neolithic eyes. Today you can still see the gutted remains on The Primrose on Google Earth.
Imagine climbing on board that ship. A completely alien vessel filled with alien things. Imagine seeing simple machines for the first time. A hinge. A latch. A wheel. Things that would instantly make sense in a satisfying way. Others would be so incomprehensible to avoid notice.
I have never been able to find out what cargo was on The Primrose in all my years of reading. There was about 100 tons of some sort of consumer product on board, and I’m curious what it was. But even absent the cargo, think about all the things that must have been on that ship.
In the 1990s, when anthropologists returned to the island to make new attempts at contact, they were met with a different attitude. Not friendly, exactly. But they were willing to accept gifts. Many would wade into the water with smiles to accept coconuts.

Here is a video of one of those encounters:

And in those videos, you can see that these pre-iron age people now had metal weapons, like the knife carried by this man. They had scavenged metal from the Primrose and cold-forged it into tools.
After collecting gifts for a few minutes, a few members of the tribe would approach and make menacing gestures, signaling that it was time for the outsiders to leave. They have never lost their desire for isolation, despite the gifts.
And they remained consistent in their intolerance against intruders. In 2006, two fishermen were killed after drifting into the island when their anchor detached while they were sleeping.
The Sentinelese are lucky they were so effective at preventing contact. The neighboring Jawara weren’t so fortunate. The tribe went from 9,000 to a couple hundred from lack of genetic immunity and only forestalled annihilation due to aggressive segregation. Their future is bleak.
Yet on North Sentinel, they’ve maintained a small community for 60,000 years which is by all indications happy. There is no way to integrate them into the modern world without wiping out nearly every member of their tribe.
And their aggressiveness is not the mark of savagery. It just that their conception of outsiders is mostly framed by some foot-faced English pervert who murdered some old people and did weird things to their kids. So let’s do them a favor and leave them alone.