How to Resolve JavaScript Conflicts on Your Joomla Website?

JavaScripts are truly a mark of creating a site with well optimized elements. While, it does provide ease in terms of performance as well as aesthetics, it also has the capability to run down a Joomla based site or cause heavy damage to it. One of the main reasons JavaScript might affect your website would be conflicting scripts. Yes, if there are internal conflicts, it can very well damage your website. In case the extensions you have loaded to your website use different JS libraries or the different libraries have conflicting scripts, you run trouble. Firstly, you need to identify the possible causes for such conflicts, and then move on to detecting the conflicts, before you plan on resolving them. Let’s understand how such conflicts occur.

Causes of JS Conflicts
It is important for you, as a Joomla developer, to understand the nature and possible causes of JavaScript conflicts. Using different Mootools library as well as jQuery library, while building your website, can become a possible cause of JavaScript conflict. In fact, the same version of these libraries, when built by different developers, can also result in conflicts that can damage your website. Conflicts also occur because of browsers. There is a possibility of conflict between the JS script of your website as well as the JS script of the browser website, while will result in issues for your website.

Detecting the Conflict
You know what the running causes of a JS conflict are; so now you need to detect these conflicts, if any, on your website, and find ways to resolve them. You should ideally run a check on the JavaScript console to identify the conflicts. You can use tools like Firebug, Web Developer Toolbar, Debugger, Error Console etc. to check for conflicts on Firefox and Chrome.

In case, your JS runs an error, then with the help of the error message that is displayed, you can easily focus on the extension or feature on the website that is the main cause for the problem. You will also see the name of the file that is majorly responsible for the conflict to get started.

To know the extension that is responsible for this conflict, here are a few steps that you can follow

  • Switch back to default Joomla, disable the installed extensions, reload the site and check for the JS conflicts and errors
  • Publish back the disabled extensions one by one, and reload the website after each installation is enabled

Resolving the Conflict
Once you have pinpointed the problem, it is time to focus on the solution. Let’s try and find a way to resolve the conflict, that might be affecting your website.

JQuery in No-Conflict Mode
This is the ideal step that you should take to resolve conflicts. The entire jQuery library and the related plug-ins are stored in the jQuery namespace. Even the global objects are stored in the jQuery namespace. You should avoid the conflicts that might occur between jQuery namespace and Mootools or other such libraries. To avoid conflict, put the jQuery namespace to no-conflict mode as soon as the page is loaded, and before getting started with the jQuery on that particular page

<!– Another way to put jQuery into no-conflict mode. –>
<script src=”/prototype.js”></script>
<script src=”/jquery.js”></script>
jQuery( document ).ready(function( $ ) {
// You can use the locally-scoped $ in here as an alias to jQuery.
$( “div” ).hide();
// The $ variable in the global scope has the prototype.js meaning.
window.onload = function(){
var mainDiv = $( “main” );

In case, you are unable to resolve the conflict by putting the jQuery in no-conflict mode, you should try to seek help from the developer of the extension.

Deepa is a passionate blogger associated with Semaphore Software. She loves sharing information regarding joomla tips & tricks. If you are looking for Hire joomla Programmers then just get in touch with her.

About deeparanganathan