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

USA VPS
OpenVZ VPS
Brazil VPS
Ubuntu VPS
Windows Cloud Server
Germany Cloud Servers
Linux KVM Hosting
KVM VPS
Linux Cloud Server
cPanel KVM

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

Linux KVM Hosting
KVM VPS
USA VPS
OpenVZ VPS
Ubuntu VPS
cPanel KVM
Windows Cloud Server
Linux Cloud Server
Germany Cloud Servers
Brazil VPS
Rate this Tutorial:
No Comments Leave a Comment
Leave a Comment

Other (195)

Popular Keywords