简体   繁体   English

在TYPO3 7.6中将javascript(或css)作为内联包含在TYPO中,并带有Typoscript

[英]Include javascript (or css) as inline in HEAD with Typoscript in TYPO3 7.6

I have a little javascript file that I need to run before my site loads (it contains some modernizr code and some more). 我有一个小的javascript文件,需要在网站加载之前运行(它包含一些modernizr代码等)。 Usually I add it using includeJS but for performance issues I need it inline. 通常,我使用includeJS添加它,但是出于性能问题,我需要内联它。 As workaround I am including it using headerData in this way: 作为解决方法,我以这种方式使用headerData包括了它:

headerData {
    10 = TEXT
    10.value (
        <script>
           // Here goes my javascript code
        <script>
    )
}

It works but it is ugly and difficult to update. 它可以工作,但是很丑陋,很难更新。 Is there a way to say something like 有没有办法说像

headerData {
    10 = TEXT
    10.value < include(../path/to/my/file.js)
}

I don't see how this is an performance improvement over page.includeJs but you can just render a template here: 我看不到这比page.includeJs有什么性能改进,但是您可以在此处渲染模板:

headerData {
    10 = FLUIDTEMPLATE
    10.file = EXT:my_ext/Resources/Private/Templates/MyTemplate
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM