Saturday 30 May 2015

How to add custom jQuery instead of default for end user theme in Drupal 7?

/* We can use hook_js_alter for altering the JS files in template.php so that the updated jQuery would be used for only the pages where this is loaded.*/
function THEME_NAME_js_alter(&$javascript) {
// Swap out jQuery to use an updated version of the library.
global $base_url;
$jQuery_version = '1.11.1';
$jQuery_local = $base_url.'/'.drupal_get_path('theme', 'THEME_NAME') . '/js/jquery-1.11.1.js';
$javascript['misc/jquery.js']['data'] = $jQuery_local;
$javascript['misc/jquery.js']['version'] = $jQuery_version;
}

No comments:

Post a Comment

Your comment is so valuable as it would help me in my growth of knowledge.