13 ms·
Twitter to move away from Hashbangs
- simonw 15y agoThis is fantastic news. From the recent tweets by https://twitter.com/danwrong https://twitter.com/danwrong it looks like Twitter are moving entirely to HTML5 pushState, and leaving IE users with full page refreshes rather than continuing to serve them #! - Dan says "I'm not sure why everyone is so adverse to page refreshes these days. You can make them fast too." Of course, Twitter are going to have to include a piece of JavaScript on the http://twitter.com/ http://twitter.com/ homepage which checks for a #! and redirects the user to the corresponding page - and they'll have to keep that JavaScript there forever, since they have nearly two years worth of links that they need to avoid breaking. One of the many reasons #! is such a nasty hack. In terms of performance, this is going to make Twitter a lot /faster/ for me - I often open Twitter profile pages in new windows (due to working on Lanyrd) and each new window has to pull in and execute a HUGE chunk of JavaScript before it will display the page. Being able to just load a regular HTML page will be much faster for me.
- joshuahedlund 15y agocan't they just do a one-line .htaccess regex replace? or is it more complicated than that?
- tkaemming 15y agoThe redirection has to be done on the client-side, because the server never receives the fragment identifier as part of the URL.
- simonw 15y agoNope, because anything after the # isn't included in the HTTP GET request made to the server - so a .htaccess-level redirection won't see it. You have to execute actual JavaScript on the client to read and redirect the #! bit.
- deleted 15y ago[deleted]
- sirclueless 15y agoThat is the fundamental problem with hashbangs: the server receives "GET / HTTP/1.1" and the client uses javascript to render the hashbang. The server has no idea a hashbang is present until after it sends javascript to run client-side.
- deleted 15y ago[deleted]
- mnutt 15y agoIt doesn't sound like they're switching to rendering on the backend, though. So you're most likely still going to have to execute a huge chunk of javascript before displaying the page, though hopefully it will get faster.
- n8agrin 15y agoDan doesn't say anything about where the rendering will happen. Most sites these day (including Facebook, Gmail, etc) have to execute "a huge chuck of js" before displaying the page. I have been told by some people in the know that they have come up with a system similar to pjax for certain page components, though that may have changed.
- dewitt 15y agoTrue for Gmail, though Google+ renders most of the initial page view in static HTML/CSS, then progressively enhances subsequent pages using JS and a variety of techniques, including embedded frames and pushState. There's a lot that goes into making G+ so fast, and pre-rendering a big is part of it. By way of comparison, view the following two links in a javascript-less browser (or just view source): $ w3m http://twitter.com/#!/danwrong/status/171680703824662528 $ w3m https://plus.google.com/117377434815709898403/posts/f35f8QvHab7 The first link contains nothing but boilerplate and the JS that lazily loads the real content, whereas the second contains the actual content ready for the client to render immediately (and index, if you're a crawler). This is a good move by Twitter. I wholeheartedly endorse it.
- pak 15y agoWouldn't they have to, to support browsers without pushState? And even if they used terrible JavaScript hackery to get around that (serve same content for every URL, have clients AJAX in content based on location.href) how would they support web crawlers? I thought the whole point of the hashbang was that you would get the original content (or an equivalent representation) by removing it from the URL, so I'd think they still support backend rendering at some level.
- 15y ago
- zeeg 15y agoTo be honest, I'd prefer maintaining a single JS redirect on the main page, rather than many server-side regular expressions trying to redirect to appropriate pages.
- nikcub 15y agoGood. A lot of developers justified doing it in their own projects because Twitter and Gawker were doing it. Now that one of the headline sites is no longer using it (and will hopefully condem it) we can file this episode to history and never speak of it again. Edit: wouldn't it be awesome if Google (they did start this, afterall) would allow sites using hashbangs to auto-update all indexed URls
- simonw 15y agoDo you know how long ago Gawker dropped them?
- nikcub 15y ago~6 months ago IIRC they constantly had problems with their redesign and the last update involved removing the hashbangs
- ianvanness 15y agoThis sounds about right, if not a little earlier. Experimental work for this was done by me here: https://github.com/ianvanness/html5history https://github.com/ianvanness/html5history I believe there were further tweaks for additional pages that needed to be supported (whereas I had only solved, and most likely not very elegantly, the rudimentary issue) that took additional time before the hash bang removal was actually launched.
- nikcub 15y agoThanks - I was estimating off the top of my head - the site was in flux for a while at the time. They also went back and forward with keeping the story sidebar at fixed positioning and it seems they settled on it not floating. I check the site every couple of weeks because I was interested in how the redesign would work out. It seems they eventually got it right, I like it. A lot of the other blogs have home and article pages that are just too heavy and slow.
- deleted 15y ago
- Nitramp 15y agoThe actual URL for the informative blog post is this: http://danwebb.net/2011/5/28/it-is-about-the-hashbangs http://danwebb.net/2011/5/28/it-is-about-the-hashbangs The linked blog post only contains some relatively meaningless Twitter messages and the hyperlink as text, not as an actual link. One of the things the post doesn't mention (it's sort of implicit in "going under the radar") is that with hash bangs, every request has double the round trip time to retrieve the initial data being displayed, as the server cannot know what data the client wants to retrieve. This makes a lot of nifty performance optimizations impossible.
- wmf 15y agoOnly inter-site links incur the double round trip (and in NewTwitter's case, serious load time); intra-site links should be faster.
- sirclueless 15y ago"intra-site links should be faster" Why? With proper caching, all you need is the new content. Which possibly entails a few KB of HTML boilerplate and a few milliseconds for the browser to render it, but the round trip is the lengthy part and you get that either way. The only thing hashbangs get you is a prettier transition.
- Lazare 15y agoNo. That link is to an OLD blog post explaining why Dan Webb (and many other people) think hashbangs are bad idea. The actual news here is that Twitter is moving away from them, which is very new and welcome news. That link is only useful for general background on the hashbang argument; it's otherwise irrelevant.
- technomancy 15y agoI've been using the mobile version on my laptop for a few months now since the hashbang was so sluggish, but this could get me to switch back.
- kylemaxwell 15y agoCan somebody explain to non-web-types why this matters, other than making the URL itself look cleaner?
- mbreese 15y agoThe fundamental problem is that when you use hashbangs, if you want the page "/#!12345" the server gets: GET / HTTP/1.1 And never knows what content the client is trying to access, until the client retrieves and processes client-side javascript. Then the client can request further information from the server. The theory is that you can make a "single-page" web-app that loads all of the javascript at once. Then went state needs to be updated, you can do it all from javascript. In practice, it didn't work as well.
- alexmuller 15y agoAnd to expand a little on what mbreese said, the basic, fundamental idea behind the URL is for a client to indicate to a server what resource it's trying to access. So it's totally broken by that #!. http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashB... is a great article.
- ceol 15y agoIt was hinted at in other comments, but when you go to http://twitter.com/#!/danwrong http://twitter.com/#!/danwrong, what you're really doing is going to http://twitter.com/ http://twitter.com/, processing a chunk of JavaScript that looks at what's after the #!, then loading up danwrong's page. This causes issues with search engines (the server has already told the crawler everything's OK, so how do you tell it the page can't be found?) and changing URLs (if you want to stop using hashbangs, you have to include an annoying piece of JavaScript on your home page forever). So now, Twitter wants to get rid of the hashbang from its URLs because of— in part— the first reason, and it's currently dealing with the second. Hope that explained a bit.
- kylemaxwell 15y agoThanks, that's what I didn't get: the stuff after the hashbang isn't sent directly to the server as part of the GET request but interpreted by JavaScript after the page starts to load.
- zaidf 15y agoI thought this was about twitter moving away from hashtags. For some reason I got a bit excited, may be because I find vast majority of hashtags to be annoying noise. That said, I know they serve a purpose in specific use cases and donno a better alternative.
- intellection 15y agoIs it un/reasonable to consider moving hashtags out of tweets and into metadata or just separate? Just as useful, but can be styled separately. Evolved hashtags, backwards compatible.
- MBCook 15y agoThat would make sense to me. I always thought it was odd that you weren't allowed to attach a link as metadata, causing the rise of all the various URL shorteners.
- logic 15y agoThe tweet still needs to fit into 140 characters, including any metadata you want visible to the recipient. Think SMS. Hence, might as well make it a user-manageable item in the tweet itself.
- MBCook 15y agoI know that was the original idea, but I wonder how many people in the last year or two receive tweets via SMS. If I was in charge, it's a tradeoff I'd be willing to make.
- logic 15y agoThe entire world is not the United States. :) "Feature" phones and spotty data service are still very common in certain regions, but SMS works almost anywhere with cell infrastructure (or via sat phones).
- johnbender 15y ago"PushState or bust" means there will be no support for IE version 9 or earlier, which makes me wonder if they'll take the approach of layering replaceState on top of the existing hashbangs thereby fixing the deeplinks issue.
- lucb1e 15y agoI especially agree with that last comment, people are so hyping over not making pages refresh for speed, they rather often trigger the opposite effect.
- jquery 15y agoTwitter's implementation of the hashbang was awful. It broke the back button and it was slow. I don't think it's a fair representation of the technique. EDIT: And based on their implementation, I wouldn't trust anything their engineers have to say about hashbangs either.
- alexmic 15y agoIn what sense did it break the back button? Back takes you to the previous thing you clicked correctly.
- Smudge 15y agoIt didn't break back. It just hijacked the browser's history by adding a 2nd page load in order to inject the "!#" into the address bar. Pressing back would, as a result, act like the refresh button.
- jamesgeck0 15y agoI don't follow you. Changing the functional behavior of the back button _sounds_ a lot like broken.
- alexmic 15y agoI'm not sure that this is the case. Back works as expected - it takes you to the previous page you were at. Fragment identifiers don't break the back button. That's all from a user perspective's point of view, which is mostly all that matters in the end. If you look at this from a technical standpoint, then back is a refresh of twitter.com, yes.
- firefoxman1 15y agoEven though Twitter has decided it's either "pushstate or bust" what sort of fallback for pushstate exists for those of us who care about all our users, not just the ones with good browsers?
- epistasis 15y agoThe fallback is a normal web request and page refresh. This seems far more caring for all of their users than the high load that the hash-bang design placed on client computers.
- firefoxman1 15y agoIn their case, yes, but the potential speed gain by pushing a lot to the client-side is great when properly harnessed.
- martindale 15y agoThank god. I've always felt uncomfortable that every link normal users share (I manually remove them) is technically pointing at their front page.
- altcognito 15y agoDan says "I'm not sure why everyone is so adverse to page refreshes these days. You can make them fast too." Rolls eyes I don't need Twitter (140 characters should be enough for any application!) telling me how "fast" their pages load. Particularly coming from the notorious fail whale.
- guelo 15y agoGood. Now if they would get rid of minified urls they would be done with their damage to the web.
- thelicx 15y agoThat totally makes sense. Time to pushState!!!
- protospork 15y agoYES! For anyone with a high latency (huge swathes of the US are still stuck with satellite or mobile and the tech industry seems to have ignored this), twitter is a nightmare. The first pageload only pulls the empty 'framework' page, then a series of js requests pull the information. You can't walk away while it loads, either, because it will register the latency and display errors instead of content.
- xpose2000 15y agoAs far as I know, the proper way to create a modern web app to deal with location.hash fallback and pushState, replaceState etc is to use https://github.com/balupton/History.js https://github.com/balupton/History.js . Comments/Corrections are welcome.
- swah 15y agoOTOH isn't this the "modern way" to develop a web app? HTML templates + AJAX on the client and a REST/JSON API that you can reuse for iOS apps on the backend?
- nkohari 15y agoI wouldn't say the re-use is specifically for iOS apps, but in general, you're right.
- zerostar07 15y agoHow about they move away from URL shorteners too?