Reputation: 27
I just wanna add my javascript file to be added while rendering the all front-end pages not the back-end pages. I have tried :
if (TYPO3_MODE=="FE" ) {
$pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->loadRequireJsModule('EXT:eyebase/Resources/Public/JavaScript/testinjectEyebaseJS.js','code');
}
but this code added my js file within the CDATA like:-
<script type="text/javascript">
/*<![CDATA[*/
/*RequireJS-Module-EXT:eyebase/Resources/Public/JavaScript/testinjectEyebaseJS.jse6fb06210fafc02fd7479ddbed2d042cc3a5155e*/
require(["EXT:eyebase/Resources/Public/JavaScript/testinjectEyebaseJS.js"], code);
/*]]>*/
</script>
Please guide me how to do this. Thanks in advance.
Upvotes: 1
Views: 4914
Reputation: 2557
You can add CSS/JS via HeaderAssets and FooterAssets sections in your Fluid template.
See TYPO3: How could I add css and js files via controller initialize action and page renderer?
Upvotes: 2
Reputation: 2921
You would put this into TypoScript ("setup" part):
page {
includeJS {
testinjectEyebaseJS = EXT:eyebase/Resources/Public/JavaScript/testinjectEyebaseJS.js
}
}
Have a look for the options here https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Setup/Page/Index.html#includejs-array.
Upvotes: 0