Gather round for some news that’s really going to shake your tree: as of version 0.55, <blink>Rollup, the JavaScript module bundler, finally has code-splitting</blink>! This has been the most popular feature request for a long time, since it lets complex apps load quickly in smaller increments while still leveraging Rollup’s obsessive focus on efficiency. Rollup has long been the tool of choice for library authors — it powers React, Vue, D3, Moment, Three.js, …


This week, Facebook merged a monster pull request into React that replaced its existing build process with one based on Rollup, prompting several people to ask ‘why did you choose Rollup over webpack’?

Which is a completely reasonable question. Webpack is one of the modern JavaScript community’s greatest success stories, with millions of downloads every month powering tens of thousands of websites and applications. It has a large ecosystem, dozens of contributors, and — unusually for a community open source project — meaningful financial support.

By comparison, Rollup is a minnow. But React isn’t alone — Vue, Ember, Preact, D3, Three.js, Moment, and dozens of other well-known libraries also use Rollup. So what’s going on? …


Audio on the mobile web is a mess. The easy way to play sound — creating an <audio> element and calling the audio.play() method — doesn’t work unless playback starts in response to a ‘user gesture’, and will only let you play one clip at a time.

The hard way — loading the audio, decoding it using the web audio API’s context.decodeAudioData(…), creating an AudioBufferSourceNode and playing that — gives you a lot more flexibility, but comes with a rather important caveat: it will crash your phone.

There’s a simple reason for that. The browser needs to store the entire audio clip, decoded, in memory, which — since a 5Mb mp3 file typically equates to a 55Mb wav file — you can quickly find yourself running out of if you’re using large audio files. When that happens, the way you find out about it is the whole tab going kaput. …


If you write JavaScript tools or libraries, you should bundle your code before publishing.

Image for post
Image for post
The internet

A few hours ago, Azer Koçulu ‘liberated’ his collection of modules from npm following a trademark dispute. One of them — an 11-line utility for putting zeroes in front of strings — was heavily depended on by other modules, including Babel, which is heavily depended on by the entire internet.

And so the internet broke.


I’ve been working (albeit sporadically of late, admittedly) on a tool called Rollup, which bundles together JavaScript modules. One of its features is tree-shaking, by which I mean that it only includes the bits of code your bundle actually needs to run.

Axel Rauschmayer asked where the term came from…

…and Amjad Masad said that it’s really just a different name for dead code elimination

…which Sebastian McKenzie thinks is silly:

But they are in fact different things, even if they have the same goal (less code).

Dead code elimination is silly

Bad analogy time: imagine that you made cakes by throwing whole eggs into the mixing bowl and smashing them up, instead of cracking them open and pouring the contents out. Once the cake comes out of the oven, you remove the fragments of eggshell, except that’s quite tricky so most of the eggshell gets left in there. …


Image for post
Image for post
Long Road Photography on Flickr, used under Creative Commons license

Once again, the turkeys have voted for Christmas. The ailing news industry has rushed headlong into an alliance with Google, which is trying to stave off its own existential threats. It’s an alliance in which we are clearly the junior partner, and one that will hobble the diversity and development of digital journalism. And it could all have been avoided.

Google’s Accelerated Mobile Pages project, or AMP, is one of those ideas that’s hard to argue with at first: an open source endeavour to create a subset of HTML that allows pages to be aggressively cached, and that limits the ability of careless web developers to create bad experiences on the mobile web by stuffing pages to the gills with badly made ads, overweight images, and six different analytics providers. Apps like Twitter (an AMP launch partner) will be able to show these pages instantly, and users will be spared a screen full of invitations to download-our-app or fill-in-our-survey before they can scroll past the ads to get to the article (which hasn’t actually rendered yet because the web fonts are still downloading). …


There’s a post currently doing the rounds that articulates the ‘small modules’ philosophy. It’s written by Sindre Sorhus, whose npm profile is enough to make all but the most prolific developer feel wholly inadequate, and so carries with it a degree of authority.

Like a lot of ideas that seem to be self-evident and inarguable, ‘small modules’ contains a lot of truth but does not, I believe, bear close scrutiny. But because it is espoused by so many leading members of the JavaScript community, scrutiny is all too rarely applied.

I think I know why: it’s because the small modules philosophy favours library authors (like Sindre) at the ultimate expense of library users. Because library authors typically have larger megaphones (more Twitter followers, more credibility on GitHub and Hacker News, etc), their voices are heard more often. …


If you haven’t read Trek Glowacki’s post Requiem for the “Front Ender”, you should. It’s essentially a follow-up to this answer to the question of whether Ember will continue to support users who don’t wish to use ember-cli. Both are beautifully written, and contain a lot of truth.

Stripped to its core, the argument is that web development is no longer a field for amateurs, but for Engineers with a capital E. (Often, when this subject is discussed online, there’s an ugly hint of triumphalism involved — of developers who have already climbed the ladder delighting in pulling it up behind them — but that’s absolutely not the case with Trek, who clearly feels a lot of sympathy for those web developers who are exhausted by the constantly shifting goalposts of our industry.) …

About

Rich Harris

Graphics editor, @nytimes investigations team. Open sourceror

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store