views:

544

answers:

1

I wrote some MooTools code that reads from YouTube's API in JSON and I want to execute it from within a custom component.

I've been reading about the js.php file, but I'm unclear on the best approach. I was just going to output js in my component directly, and then i realized that the MooTools library isn't being loaded unless a component specifically requests it.

Furthermore, part of my code was to dynamically load a remote JS Library, and then to remove it from the DOM when I needed. Can all this be done within Joomla's Framework?

Can someone help?

A: 

So it appears, there is a command in the framework that instantiates mootools, and several other commands for loading scripts into the DOM:

JHTML::_('behavior.mootools');

$doc = JFactory::getDocument()
$doc->addScript($scriptURL);

or a shortcut(from API docs):

JHTML::script(string $filename, [boolean $path = 'media/system/js/'], [ $mootools = true])

The thing is Joomla1.5 uses an older version of MooTools (1.1), and the next version that's going to be released is 2.0, so it's pretty far behind.

There are some interesting built-in features with the JHTML class, but I'm opting to use JQuery for most everything at this point - as updating MooTools will actually break many features in Joomla, and jQuery is much more lightweight.

FilmJ