Posted by gausarts on September 1, 2012 at 6:29am
24 followers
| Project: | jQuery Update |
| Version: | 7.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
I am not sure if this is a good idea, but my main reason of using JQuery Update is front end, not drupal admin, not sure about others.
Comments
#1
+1
Is it possible to only perform jQuery update to the front end?
#2
This would amount to jQuery Update settings per theme. On sites that don't use Drupal's built in jQuery UI and ajax features, replacing with the latest jQuery on the front end theme could be nice. There would be a performance hit for site owners/ authenticated users though, having to download two versions of jQuery. Couldn't hurt as an option though.
#3
Great idea. This has to be an option.
#4
A workaround
<?php
/**
* Implements hook_module_implements_alter().
*/
function hook_module_implements_alter(&$implementations, $hook) {
if ($hook == 'library_alter') {
// 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'];
unset($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';
}
}
?>
#5
gagarine,
Cool technique! Works well for me.
Thanks for sharing,
Chris
#6
cpliakas, I toke the time to write a blog post about http://antistatique.net/blog/2013/01/04/drupal-use-a-different-jquerys-v... hop that's help some peoples.
#7
Cool, thanks gagarine, this works for me.
#8
Hi, I'm using this to allow block-like path selection for replacement
#9
Updating status
Note: The patch in #8 works for me
#10
Marking this as a duplicate of #1524944: Allow different version for administrative pages
#11
I've pushed #1524944: Allow different version for administrative pages back to Needs Work so the path functionality from this issue can be merged into it.
#12
The workaround in #4 works pretty good for me, but we ran into fatal errors when deploying this to the test server combined with features and drush -fra, because the hooks were invoked before jquery_update was enabled. Here is an improved version of the workaround which prevents that problem with module_exists('jquery_update').
<?php
/**
* Implements hook_module_implements_alter().
*/
function hook_module_implements_alter(&$implementations, $hook) {
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'];
unset($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';
}
}
?>
#13
@muka Thanks for the patch! The workaround posted in #12 did not work for me