This post was originally going to be titled Why is Twitter Still Hash-Banging Away?, because I've
long been wondering why Twitter has not dropped the hash-bang—that ugly '#!
'—from its
URLs. My question was answered earlier today when Dan Webb
tweeted that Twitter would be getting rid
of its hash-bangs once and for all:
The story of the hash-bang goes back to the early days of 'AJAXed' websites. (For the uninitiated, 'AJAX'—which stands for Asynchronous Javascript and XML—is a technique used to load and display new content without reloading the rest of the page.) Back then, most browsers had a security restriction which prevented sites from using Javascript to change the URL in the address bar, which meant that jumping from example.com/page-one to example.com/page-two was not possible using AJAX.
'AJAX' is a misnomer—It need not be asynchronous, nor use XML, nor
even be written in Javascript
However, a portion of the URL called the fragment
identifier—anything that comes after a
'#
'—could be modified without requiring a page reload. As a result, many sites began
inserting the '#
' into each page's URL, which got the job done despite a few quirks. There was
just one problem—most of these pages were no longer crawlable by search engine spiders, as
they typically ignored any Javascript.
Google saw this and had an idea for saving these poor, lost websites. They came up with a long
specification for
web developers, introducing a new crawling scheme for AJAXed websites. By using hash-bangs (#!
)
instead of hashes (#
), developers could indicate that their site supported this scheme and could
be indexed like a normal website. The catch was that all URLs would need to work properly when the
nonsensical string '?_escaped_fragment_=
' was inserted in place of the hash-bang. Normal visitors
would never have to see this behavior, of course, but it was important for playing nice with search
engines.
Sounds a bit convoluted? It is.
The web was going through some serious growing pains, and Google's solution was complex and awkward, despite its rapid adoption. Before long, a web developer named Mike Davies posted a rant which argued that sites making use of hash-bangs were actually "breaking the web." He was not alone, and many others followed with similar arguments.
Perhaps one of the worst offenders in hash-bangery, as Davies pointed out, was Gawker Media, whose web designers implemented a jarring, AJAXed redesign across their network of weblogs. Visitors despised the site's new behavior, and many soon discovered that traditional URLs were quite literally broken when Javascript was turned off. Instead of rolling-back the changes, Gawker wore its new, trendy layout with pride, and consoled frustrated readers by creating a "Gawker Redesign" support forum.
Twitter jumped on the bandwagon as well, with what became known as #NewTwitter—not to be
confused with the more recent #NewNewTwitter—and visitors immediately started complaining
that the site was 'hijacking' their back buttons. In reality, Twitter was adding an extra page load
to inject the #!
into its URLs, which did not play nicely with browsers' page histories. The
resulting 'fix' actually came from the browsers themselves, and not from Twitter.
the hash-bang didn't break Gawker.
All
of this voodoo-hackery was, some argued, a necessary part of the modern web. After all, how else
could web designers create AJAXed pages with proper URLs? There were plenty of sites making
perfectly innocent use of hash-bangs, without any audience outcry.
Gawker Media broke themselves.
The argument was finally put to rest in mid-2011 when the History API, also referred to as
'PushState,' came sailing along on a wave of other HTML5 features. By removing security
restrictions and allowing sites to modify their URLs on the fly, the History API fixed the problem
at its source. No longer were #
's or #!
's required for sites to perform their AJAX magic. The
web had finally completed its long-drawn transition from a dull repository of static pages to a
world of rich, interactive applications.
And that brings us back to Twitter. Why, exactly, has it taken almost a year for one of the most
influential sites of its time, a bright and shining beacon of the modern web, to acknowledge this
obvious feature? And when will they finally implement it? The aforementioned #NewNewTwitter came
and went without any indication that the plague of #!
's would ever go away. It is long past time
for Twitter to stop mangling its URLs with an outdated hack.