I was doing some testing for a project where I wanted to ensure that the user still could reach certain functionality even with JS disabled. I wanted to quickly find something by going to Google and I immediately started typing like I usually do - thanks to auto-focus. While I was typing, the input was empty and I realized JS is disabled and did some inspection to the input form and found that it did not have the auto-focus attribute.

Does anyone have any reason to why Google would choose not to use simple auto-focus attribute and only depend on JS for this functionality?

I noticed the same thing on this site too, perhaps someone has a better explanation why big applications wont use such attributes which I think we should be promoting in the first place.

  • It' not a bug; it's a feature.
    – user44167
    Commented Feb 26, 2014 at 9:18
  • 1
    I do know it's a feature but why would they implement such a feature using JS instead of a simple autofocus attribute?
    – Shina
    Commented Feb 26, 2014 at 9:29

2 Answers 2


Just to answer the question with a question:

Are there contexts where auto-focusing doesn't make sense?

I think there are.

If a device has JS, you can make certain assumptions about the kind of user interface that device offers and therefore, you can make a reasonable guess as to their accessibility requirements and what would be the best user experience for them.

I would suggest that this might not be the case for other devices. Screen readers and other devices often have different accessibility requirements to JS enabled devices. Auto-focusing for these types of devices could have quite a disruptive effect causing the screen to jump to the input element which, in turn, would cause the user to loose context and feel less in control of their experience.

Accessibility and usability are not the same and can sometimes be difficult to balance. I think Google have made the right choice here - accessibility should always win.

  • This is a great answer! The context of accessibility is often overlooked when it comes to usability features.
    – discorax
    Commented Mar 27, 2014 at 18:05

I don't work for Google so I am only guessing here, but I suspect it could be to do with file-size.

Patchy browser support means that they still need to have a javascript fallback for giving focus to the input field. Implementing the autofocus attribute means extra bytes in the html and extra bytes in the javascript (to only implement the javascript when autofocus is unsupported).

As the vast majority of their users have javascript enabled they may as well stick with the pure javascript option and save the bandwidth.

Obviously, when browser support improves they can drop the javascript entirely and switch to the autofocus attribute.

  • Makes sense but does it hurt in anyway to have both the autofocus attribute and their JS autofocus just as a fallback for JS disabled browsers since they wanted the autofocus in the first place. On this site, it is exactly the same when creating a new question.
    – Shina
    Commented Feb 26, 2014 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.