Skip the navigation

Longest Web API type names

Published on

728 words

Table of contents

If you've browsed MDN recently, you may have noticed some Web API types with really long names, including such bangers as ReadableStreamDefaultReader and FileSystemWritableFileStream. If you've ever thought "I wonder what the longest one is", you're in luck — this is exactly what this post is about.

The names

Section titled 'The names'

50+ characters

Section titled '50+ characters'

40+ characters

Section titled '40+ characters'

30+ characters

Section titled '30+ characters'

25+ characters

Section titled '25+ characters'

How to reproduce this list

Section titled 'How to reproduce this list'

Use the following Node script. It uses the WebIDL definitions from every Web standard to do its job. And yes, I am as surprised as you that they not only have a JavaScript API for this, but it's also all in one place and easy to use.

import idl from "@webref/idl";

const specs = await idl.parseAll();
const asts = Object.values(specs);
const definitions = asts.flat();

const allNames = definitions
    .map(definition => definition.name)
    .filter(name => name != undefined);

const uniqueNames = Array.from(new Set(allNames))
    .toSorted((a, b) => b.length - a.length);

const THRESHOLD = 25;
const longNames = uniqueNames.filter(name => name.length >= THRESHOLD);

const byCharacters = name => Math.floor(name.length / 10) * 10;
const namesByCharacters =
    Object.entries(Object.groupBy(longNames, byCharacters))
    .map(entry => ({characters: entry[0], names: entry[1]}))
    .toSorted((a, b) => b.characters - a.characters);

for (const group of namesByCharacters) {
    const characters = group == namesByCharacters.at(-1)
        ? THRESHOLD
        : group.characters;

    console.log(`### ${characters}+ characters\n`);

    for (const name of group.names) {
        console.log(`* \`${name}\``);
    }

    console.log();
}