I am developing a component in joomla 3. What is the best practice to add external css and js files to it located in mySite/media/com_myComponent/css and mySite/media/com_myComponent/js?
To add css and js files in Joomla 3.x, you should use JHtml
, like so:
JHtml::_('script', 'http://some-external-site.com/file.js');
JHtml::_('stylesheet', 'http://some-external-site.com/file.css');
If they are on the same server as your component AND in media/com_myComponent
, then use the following:
JHtml::_('script', com_myComponent/js/file.js', false, true);
JHtml::_('stylesheet', 'com_myComponent/css/file.css', false, true);
Hope this helps