Disable user_node_load Is there a way to disable user_node_load on non-admin pages without hacking core modules? My theme doesn't use user data so this function results in needless database queries.
Disclamer

I am using a hook in a way that is different from the usage that is documented on Drupal.org API. See the notes at the end of the question.

You could achieve what you want by implementing two hooks:


hook_module_implements_alter()  

function mymodule_module_implements_alter(&amp;$implementations, $hook) {
  if ($hook == 'node_load') {
    unset($implementations['user']);

    // Put mymodule_node_load() to the beginning of the list.
    $group = $implementations['mymodule'];
    unset($implementations['mymodule']);
    $implementations = array('mymodule' =&gt; $group) + $implementations;
  }
}

hook_node_load()

function mymodule_node_load($nodes, $types) {
  if (path_is_admin($_GET['q'])) {
    $uids = array();
    foreach ($nodes as $nid =&gt; $node) {
      $uids[$nid] = $node-&gt;uid;
    }

    $user_fields = db_query("SELECT uid, name, picture, data FROM {users} WHERE uid IN (:uids)", array(':uids' =&gt; $uids))-&gt;fetchAllAssoc('uid');

    // Add these values back into the node objects.
    foreach ($uids as $nid =&gt; $uid) {
      $nodes[$nid]-&gt;name = $user_fields[$uid]-&gt;name;
      $nodes[$nid]-&gt;picture = $user_fields[$uid]-&gt;picture;
      $nodes[$nid]-&gt;data = $user_fields[$uid]-&gt;data;
    }
  }
}



The code I used for hook_module_implements_alter() is different from the example code shown in the documentation, which just alters the order in which different implementations of the same hook are invoked.

function hook_module_implements_alter(&amp;$implementations, $hook) {
  if ($hook == 'rdf_mapping') {
    // Move my_module_rdf_mapping() to the end of the list. module_implements()
    // iterates through $implementations with a foreach loop which PHP iterates
    // in the order that the items were added, so to move an item to the end of
    // the array, we remove it and then add it.
    $group = $implementations['my_module'];
    unset($implementations['my_module']);
    $implementations['my_module'] = $group;
  }
}


In general, it is not a good idea to avoid a hook implemented from another module is invoked. Modules that change their behavior because a hook implemented from another module is invoked normally use module_exists(), rather than module_implements(), which means those modules normally make the assumption that the module being enabled is sufficient for that specific hook to be invoked.
Generally speaking, there could be modules that depend from the data injected from the hook you are trying to block. It is not said that avoiding user_node_load() executes its SQL queries would avoid another module executes its own SQL queries with a decrement of performance even worse.

If you are sure that none of conditions I described are verified, you could implement the code I shown, at your own risk. Be prepared to verify there aren't any unwanted consequences, and check what the code used by the modules you use in the site is doing.