Multiple Jquery VersionMultiple Jquery Version
2016 17 Feb

Multiple Jquery Version

By Basant Sharma

Many times you need to work with more than one jquery version, especially if you are working with drupal6. Most of the funky jquery plugins doesn't work with jqeury 1.4 and below. And you can't upgrade drupal jquery to some higher version using best practices. On the other hand using hacks (changing core files) can cause problems with Drupal bootstrap, core modules, etc.

Best way to combat this situation is to use jquery noConflict() function. Add following lines to page.tpl.php above 'php print $scripts'  

 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> (replace this with the version you want to use)
<script type="text/javascript">
var $jq = jQuery.noConflict();
</script>

Then replace the $ with $jq inside the jquery files where you want to use above jquery version or simply put the content of those jquery files inside the following tags

(function($){
..
...
..

})($jq)

And that's it, in this way you can use more than one jquery version within a single drupal installation.

 

    Latest Blogs

    intor_react

    Introduction to React JS and Components

    React is a flexible JavaScript library for building user interfaces and it lets you compose complex UIs from small and isolated pieces of codes which is known as Components.

    Read More

    Flexbox

    How to simplify the layout of your website using Flexbox?

    Have you ever scratched your head while working with CSS to make some simple layouts for your website? Are you fed up of running to the UI developers for small layout designs every time?

    Read More

    cache_context

    Drupal 8 Cache Context: An efficient way for context based caching.

    We are well aware of the fact that Drupal Cache API is a remarkable feature introduced in Drupal 8.

    Read More

    CacheImg

    How does entity cache work in Drupal 8

    The Drupal Cache API is used to store data that takes a long time to compute.

    Read More