views:

350

answers:

1

Anyone have any experience of using Closure js lib and Mootools in the same page?

Conflicts or works ok?

+1  A: 

According to google:

The names of all Closure Library functions and properties begin with a dot-delimited path that prevents them from accidentally overlapping with names defined in non-Closure Library code. This path is called a namespace.

(http://code.google.com/closure/library/docs/introduction.html)

So there should be no conflicts, also I checked the API documentation and it reaffirms my findings, for example, for array manipulation you have to go through the google namespace (goog):

goog.array.binaryInsert(array, value, opt_compareFn)   ⇒
boolean

(http://closure-library.googlecode.com/svn/trunk/closure/goog/docs/closure_goog_array_array.js.html) This is unlike the MooTools extention of the Array class itself.

Cheers, Roman

Romansky
thanks - does the MooTools extension methods mean they would be incompatible with Closure lib then?
rutherford
it can be incompatible with anything, if not coded carefully. depends largely on how you structure code. if the array prototype has been modified and you iterate an array without that in mind, you could end up getting iterations of the prototypes as well... iirc there was some critique of closure by the author of Raphael to do with lack of hasOwnProperty checks in such iterations... so keep that in mind.
Dimitar Christoff
I would just use the MooTools array traversal code ($each()), wouldnt be the real reason to use the google library in the first place I presume. having said that I havent had any issues with other big libraries (OpenLayers) while using MooTools, so its all in good taste!
Romansky
ok, I'll take that as a guarded yes to compatibility :)
rutherford