Add focus to user login I'm trying to add:

drupal_add_js('jQuery(document).ready(function () { jQuery("input#edit-name").focus(); });', 'inline');


to the user login page when the user is not logged in. This lack of login form focus is one of my worst web annoyances.

What would be the most efficient way to do this?

I can add the code to every page by adding it to my theme's js, but this is inefficient.

In the theme's template.php I can use theme_preprocess_page() and check for $variables['logged_in'] but how do I test for only the /user page?
You can use the drupal_match_path() function: 

$path = drupal_get_path_alias();
$pattern = 'user';

    if (drupal_match_path($path, $pattern)) {
      drupal_add_js('jQuery(document).ready(function () { jQuery("input#edit-name").focus(); });', 'inline');
    }