distante
distante

Reputation: 7025

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). Usually I add it using includeJS but for performance issues I need it inline. As workaround I am including it using headerData in this way:

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)
}

Upvotes: 0

Views: 2548

Answers (1)

Daniel
Daniel

Reputation: 7036

I don't see how this is an performance improvement over page.includeJs but you can just render a template here:

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

Upvotes: 2

Related Questions