JavaScript library hell

One of my current responsibilities is to update a site that has Joomla as its CMS. So I am using Joomla, and I find it very cumbersome to work with. I do not like it at all. I cannot recommend Joomla to anyone. One of the things that annoy me most is the difficulty of adding pictures to the site. And, generally, I find the Joomla interface unintuitive and cumbersome to use.

The site, as it was handed to me, produced subtle JavaScript errors in the slideshow pages. I searched the Internet for information about them, but found nothing. So I decided to determine the cause of the errors myself.

I saved one of the offending pages on my desktop and began to analyse it. After some testing, I concluded that the page, which was created automatically by Joomla, used both the MooTools framework and the Prototype framework, and these two frameworks are incompatible with one another.

I searched the Internet again, this time for this incompatibility, and I found that this incompatibility is known.

To prove beyond doubt that these two frameworks are incompatible with one another, I performed the following test:

I went to the MooTools page in Wikipedia and copied the excellent example of polymorphism that is at the end of the article. This example is implemented with JavaScript and the MooTools framework. I copied the example in a text file that I named test.js.

I downloaded the MooTools framework from http://mootools.net/download. This is a single JavaScript file named mootools-1.2.3-core-nc.js.

I downloaded the Prototype framework from http://prototypejs.org/download. Again, this is a single JavaScript file named prototype.js.

I then created three HTML pages, in order to prove the incompatbility. I tested the HTML pages by opening them in IE. For these tests, a web server is not necessary, because these are static web pages.

The first page is named NoPrototype.html and references the MooTools framework and the test.js script that needs it.

<html>
<head>
<script src="mootools-1.2.3-core-nc.js" type="text/javascript"></script>
<script src="test.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>

The script test.js runs perfectly and no errors are produced.

The second page is named PrototypeBeforeMooTools.html and it references the Prototype framework, in addition to the MooTools framework and the test.js script. The Prototype framework is referenced before the MooTools framework.

<html>
<head>
<script src="prototype.js" type="text/javascript"></script>
<script src="mootools-1.2.3-core-nc.js" type="text/javascript"></script>
<script src="test.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>

The script test.js runs perfectly, but JavaScript errors are also produced. These errors prove the incompatibility of the two frameworks.

The third page is named MooToolsBeforePrototype.html and here the Prototype framework is referenced after the MooTools framework.

<html>
<head>
<script src="mootools-1.2.3-core-nc.js" type="text/javascript"></script>
<script src="prototype.js" type="text/javascript"></script>
<script src="test.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>

Here the script test.js does not run and JavaScript errors are also produced.

So I have proven that Prototype and MooTools are incompatible and Joomla should not have been using them simultaneously on the same HTML pages.

Please note that test.js has nothing to do with the Prototype framework. I included the Prototype framework in last two web pages to show the incompatibility of the two frameworks (MooTools and Prototype). The script test.js only needs the MooTools framework.

Advertisements

About Dimitrios Kalemis

I am a systems engineer specializing in Microsoft products and technologies. I am also an author. Please visit my blog to see the blog posts I have written, the books I have written and the applications I have created. I definitely recommend my blog posts under the category "Management", all my books and all my applications. I believe that you will find them interesting and useful. I am in the process of writing more blog posts and books, so please visit my blog from time to time to see what I come up with next. I am also active on other sites; links to those you can find in the "About me" page of my blog.
This entry was posted in Web design. Bookmark the permalink.