Why Twitter doesn’t count

If you're a Twitter user, you might be wondering why Twitter suddenly stopped updating the character count when you write a new tweet in Opera.

Why? Well, this is how they decide what events to listen to in order to update the counter:

if($.browser.mozilla){
  A.push("input","keydown","keyup")
}else{
  if($.browser.webkit){
    A.push("textInput","keydown","keyup")
  }
}

A stunning display of entirely pointless browser sniffing, given that registering a listener for an event the browser does not support is a harmless no-op. Dear Twitter, I'm ashamed of you.

Aside, here is some fascinating reverse engineering of the Trending Topics algorithm, demonstrating that Twitter pretty much fails to give us a real picture of what is being most discussed on the site: How Twitter kept Wikileaks from trending, and why.

So that's the way mass media 2.0 go tabloid – through algorithms that favour trivia over substance.

Advertisements

27 thoughts on “Why Twitter doesn’t count

  1. New twitter UI. Artur yea the new version wasn't working very well but with the latest Opera and maybe things that twitter did its faster..but its still away from the way the old UI worked.

  2. Twitter suddenly stopped updating the character count

    In 10.63 it works correctly. More irritating is that the new version of Twitter completely does not work on Opera for some days.

  3. Originally posted by hallvors:

    if($.browser.mozilla){A.push("input","keydown","keyup")}else{if($.browser.webkit){A.push("textInput","keydown","keyup")}}

    Wow, that tops this quicky. And is it just me or would it make much more sense to write ($.browser.mozilla || $.browser.webkit)? Not that I'm endorsing this insanity.On a very related note, Twitter seems to load in at about 1MB total for me, and I bet that's all compressed, minified, etc. Are they loading some kind of compatibility library for IE5 or something, wtf?

  4. Originally posted by Frenzie:

    And is it just me or would it make much more sense to write ($.browser.mozilla || $.browser.webkit)?

    if($.browser.mozilla){

    A.push("input","keydown","keyup")

    }else{

    if($.browser.webkit){

    A.push("textInput","keydown","keyup")

    }

    }

    😉

    //Edit: I dont know why my line breaks are not shown in the comment :left:

  5. Oh, right you are. I missed that. Why the heck do they require different elements or whatever for different browsers? I bet that certainly contributes to the 1MB download just to display 2kB worth of Tweets.Even thinking extremely generously I couldn't imagine how to reach that.50kB page (that's huge, but what the heck)100kB scripts (even with jQuery that's huge)50kB stylesheets (again, way bigger than you should ever need)4kB * 50 pictures = 200kB pictures (now here you can't actually save much)Grand total: 400kB.That's about the very largest I can possibly envision, yet Twitter reaches 1MB.A random search result page on, say, Google doesn't look too different from Twitter and it's a total of about 70-80kB.Ixquick is much more wasteful (due to table abuse) and manages to reach about 200kB.Twitter's markup also looks relatively excessive (each little element has a DIV around it), but it's all generated client-side anyway, so if anything it should be *smaller* than if it were a proper HTML page.

  6. Twitter probably has some gradual roll-out of new code and the ability to have several versions "live" at a time, since it seems some of you got working code all the time. Now it's working again for me too. That was fast, thanks Twitter :)The fix? Here's what they changed to:

      var A=["paste","change","mousedown","mouseup","keyup"];
      if($.browser.mozilla){
        A.push("keydown","input")
      }else{
        if($.browser.webkit){
          A.push("keydown","textInput")
        }else{
          A.push("keypress")
        }
      }

    So: "keyup" is moved into the array outside the browser sniffing, to listen to keyup in all browsers (a sensible event for updating character count!). The missing "else" branch after the WebKit one is added, and they have decided to listen to keypress events in browsers that are not Gecko/WebKit based.I would still simplify that code and kill the sniffing completely, but at least adding the missing else to handle browsers they don't look for is a touch of sanity.

  7. Opera's 'input' event support is quite a bit better now (it even fires after spellcheck corrections) and only has a few bugs. Would be nice to get that working 100% and have them use *only* that.The main bugs are that the event isn't triggering on drag n drop of text and that the event is triggered when there's actually no change (which isn't as harmful, but still incorrect).

  8. When you have free time, any time, can you explain why a "modern" site wouldn't ask a browser what can it do rather than what is it?I remember Apple was also advocating it before massive success of iphone/pad and their attitude changed a bit.For example, how many lines would it require to ask browser whether it can live count characters or not?I am afraid it is easier and even web 2.0 companies who only relies on browser/os/device independent access can't code it? Why?

  9. Originally posted by Ilgaz:

    For example, how many lines would it require to ask browser whether it can live count characters or not?

    The counting is a piece of cake and can be done in just about any browser that supports Javascript. I tried to test IE3, but it wouldn't load due to insufficient memory in the 16-bit subsystem, whatever that means. At any rate, IE4 and Opera 4 can count characters perfectly fine, though I really wouldn't have needed to test that.The "hard" part would be the selection of what needs to be counted (i.e. getElementById vs. document.forms.whatever or some such) and adding eventlisteners to said element, but since Twitter doesn't support IE6 (it might be able to display tweets, but you can't even log in) I think we can safely say that Twitter supports only a subset of what jQuery does, which, by the way, has already done all that I just spoke of so you don't have to. Or in other words, using jQuery one could suffice with a single line for all browsers supported by jQuery. Not using jQuery you might have to add in some capability testing yourself.

  10. Originally posted by Frenzie:

    I tried to test IE3

    IE 3 did not have javascriptThe last version of IE for mac did not even have a JavaScript engine

  11. I'm fairly sure that JScript 1.0 was introduced with IE3, but it's not important whether it was or not (plus I have no clue about just how limited its capabilities were). The point is that it should be easy to write a counter that works in the vast majority of browsers that support some ECMAScript-like scripting language, and presumably even without any need for a fallback to '90's style scripting as long as you don't care about browsers older than about IE5/NS6 (which you really shouldn't and Twitter clearly doesn't).

  12. Originally posted by Jurgi:

    But it was (and is, I'm still on 10.63) working here…

    No, it was not working in 10.63 either when it wasn't working in 11.

  13. Well, they are still using jsquery, meaning they are lame enough either to manage crossbrowser issues themselves, or to hire some competent web-developer to do it for them.

  14. Off topic: Anyone know what's happening with my.opera members by updated status? Keeps going to 'by account age' instead of updated status.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s