I have installed jQuery Update but it breaks some core functionality that makes the admin UI a struggle to deal with. Is there a way to keep jQuery Update enabled but disable it when the admin theme is visible?


It should be noted the underline issue is really a core problem which is now fixed over at http://drupal.org/node/1480568

Anyways if people still need a fix for this this is what I have in place.

 * Implements hook_module_implements_alter().
function hook_module_implements_alter(&$implementations, $hook) {
  // Make sure to check if the module is enabled or this will cause fatal errors
  if ($hook == 'library_alter' && module_exists('jquery_update')) {
    // Move jquery update to the end. This will make sure our hook_library_alter
    // is always called before the jquery_update.
    $jquery_update = $implementations['jquery_update'];
    $implementations['jquery_update'] = $jquery_update;

 * Implements hook_library_alter().
function hook_library_alter(&$libraries, $module) {
  // If it is an admin path all we want to do is change the global $conf
  // variable so when jquery_update runs right after us it will use 1.5.
  if (path_is_admin(current_path())) {
    // Modifying global $conf variable, can be dangerous. Be carefull.
    global $conf;
    $conf['jquery_update_jquery_version'] = '1.5';

This changes the variable right before jquery_udpate uses it when is an admin path. Also this doesn't hard-code to checking the url 'admin' because and admin path can also be /node/1/edit etc..

  • FYI, The latest jquery_update version has an configuration screen that allows you to switch version between the front-facing site and the administration site. – ericduran Apr 5 '13 at 16:19

There is an open issue about this with a patch, but I have not tested it yet.

Keep in mind that you may also need to tweak the patch so that ctools paths get excluded, too, as the updates can cause problems with the ctools popups. You may also need to add in logic to detect the node add and edit pages.


Unfortunately this will be pretty difficult to do (unless there's a hack I'm not thinking of).

The jQuery Update module replaces jQuery/jQuery UI and other associated javascript files at the library level in the jquery_update_library_alter() function. The data from that hook is cached and used system-wide.

So, even if you cleared the caches on every page load, AND implemented your own hook_library_alter() that reset all of the libraries back to their original state for admin pages only, the changes would be made system wide; visitors to the front end of the site would also be using the original libraries.

Even if that is acceptable (which I can't imagine is the case), you would still need to reverse engineer the changes made by jQuery Update for your own hook_library_alter() implementation.


A sort-of hack did come to mind; you could implement hook_js_alter() (at the theme or module level) and manually replace the updated jQuery files with the old files. It would still require working out which of these files you needed to replace, but it would solve the problem without having to clear the caches on every page load.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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