function serveJs($clear = true) { if ($this->_js == '') { return; } if ($this->_echo) { parent::serveJs($clear); return; } $document = JFactory::getDocument(); $document->addScriptDeclaration($this->_js); if ($clear) { $this->_js = ''; } }