My goal is to include my Google Tag Manager script before the style definitions in order to optimize the loading order and prioritize font-family rendering. Currently, I achieve this by:
page.includeCSS {
file1 = fileadmin/templates/css/bootstrap.css
page.includeCSS.file1.media = all
file2 = fileadmin/templates/css/style.css
page.includeCSS.file2.media = all
file3 = fileadmin/templates/fontawesome/css/all.min.css
page.includeCSS.file3.media = all
}
page.headerData {
10 = TEXT
10.value (
<script data-cookieconsent="ignore">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXXXXX');</script>
)
}
The default behavior of Typo3 inserts headerdata after style definitions, but I believe it can also be placed before. However, I am unsure of how to accomplish this without compromising CSS concatenation and compression.