$url = "components/com_mycomponent/assets/js/script.js";
$document = JFactory::getDocument(); $document->addScript($url);
N.B.: It used to be possible with JHTML. However, this was deprecated in Joomla 2.5 and removed in Joomla 3.x.