For fast page load I need to insert JS at the end of the page from components and modules.
The following way of declaring scripts does not work to insert it at the bottom because there is no parameter to put it in footer.
$rsws_document = JFactory::getDocument();
$rsws_document->addScript();
So what is the concise ways to fulfill my purpose? If joomla does not provide such functionality then it's a significant drawback for page load speed.
I also want to add custom stylsheets from a module so they are injected to page only once even if same module adds it multiple times in that page -
<style type="text/css"> .classname { color:red; }.....</style>
How can I achieve this?