We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

Tutorials

More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsCMS TutorialsDrupal

How to override jQuery core JS with a newer version and include it on every page

Cloud Servers 727 x 90

When upgrading Drupal and jQuery, some damage may be done to jQuery scripts. To avoid damaging jQuery scripts that are included in every page, you need to override the core of jQuery.

One of the possible solutions would be adding a specific function in the template file which would keep template files clean. An example function would consist of the following code entry:

1
2
3
4
5
function get_scripts(){
$js = drupal_add_js('sites/all/themes/common/js/jquery-1.2.2.min.js', 'core', 'header');
unset($js['core']['misc/jquery.js']);
print drupal_get_js('header', $js);
}

It needs to be added to the “template.php” of the currently activated theme file. This file can be usually accessed by going to the Drupal\themes directory and opening the “currently activated themes” folder

Finally, open “page.tpl.php” which is located in the “templates” sub-folder of the current theme. Then, find the line “<?=$scripts?>” and replace it with “<?=get_scripts()?>”. Once applied, this method should override

Rate this Tutorial:
No Comments Leave a Comment
Leave a Comment

Cloud Servers 1 230×230

Other (195)

Popular Keywords

Web Banner 1 230×230