Rohit Chauhan
Rohit Chauhan

Reputation: 631

Is it Ok to use 2 Javascript Libraries on One HTML Page?

I know PHP and MVC but when I work on Joomla I dont want to learn Mootools for AJAX , I rather include jQuery which I know thoroughly. I think IMHO jQuery has the largest mindshare in AJAX Libraries.

When I work on Magento , instead of using bundled prototpye , I use jQuery . Same is the case with SocialEngine where I dont use the bundled mootools , but jQuery what I know better.

Personally I think it is ok to include 2 Javascript Libraries on one HTML Page because it doesnt puts any Extra Procesing load on the Server . Even in the Client Browser I dont find any performance Issues . Moreover , since jQuery is loaded from Google CDN so there is every chance that Browser Cache already has it .

What do you think , Is it ok to include 2 Javascript Libraries on 1 HTML Page ?

Upvotes: 3

Views: 1083

Answers (4)

Savageman
Savageman

Reputation: 9487

There is no particular problem if you don't use 2 libraries which alter the prototypes.

jQuery doesn't do that so you can use it with any other library.

The major librairies which alter the prototypes are MooTools < 2, dojo < 2 and Prototype < 2.

Upvotes: 0

Pat
Pat

Reputation: 25675

It's technically ok as long as the libraries don't conflict with each other (i.e. both try to bind the $ as a function) and you don't notice terrible performance for your end users.

That being said, each javascript library that you include adds extra requests and processing on the client side. While you may not notice an impact on your development computer (usually a high powered beast), you end users on their $200 laptops may not be so fortunate.

As much as possible try to only include the portion of the library that you need and concatenate libraries into a single file to cut down on the HTTP requests.

Upvotes: 3

jWoose
jWoose

Reputation: 177

Yes this is done all the time. View source on this page and you will see at least 2 included libraries.

Upvotes: 0

M4N
M4N

Reputation: 96561

I don't see a reason why you shouldn't be able to use more than one library at the same time. In some cases you will have to take care of possible conflicts, e.g. if both use the $ symbol/function.

See this page for more information: Using jQuery with Other Libraries

Upvotes: 0

Related Questions