For my extbase extension I need a CSS that I include in all actioncontrollers with:
$this->response->addAdditionalHeaderData('<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/css/mystyle.css" />');
If I now have a page where multible plugins of my extensions are included, I have multible CSS includes:
<link rel="stylesheet" type="text/css" href="typo3conf/ext/myext/Resources/Public/css/mystyle.css">
<link rel="stylesheet" type="text/css" href="typo3conf/ext/myext/Resources/Public/css/mystyle.css">
I could also do the following:
$GLOBALS['TSFE']->additionalHeaderData[100] = '<link ...>';
But as far as I know is that just the old way.
After years I use vhs:asset
now to add CSS/JS to extensions:
<v:asset.script path="EXT:my_extension/Resources/Public/js/javascript.js" name="collectionjs" standalone="1" />
<v:asset.style path="EXT:my_extension/Resources/Public/css/style.css" name="collectioncss" standalone="1" />
The name
attribute is unique, So if you have another include with the same name, it will overwrite the old include.