#90208includeJS + defer does not work if the ResourceCompressor has done its job
Description
I use Typo3 9.5.13.
According to the documentation the attribute defer is supported:
defer:
[[https://www.w3schools.com/tags/att_script_defer.asp]]
Here is an example typo scripting:
page.includeJS.a2hs = /fileadmin/a2hs/a2hs.js
page.includeJS.a2hs.defer = 1
But unfortunately the defer attribute is not included in the HTML source code.
After my analysis the defer flag arrives in PageRenderer and is placed in the array $this->jsFiles. But then comes the ResourceCompressor:
In the method
@ResourceCompressor#concatenateJsFiles(array $jsFiles)@ will “forget” the defer flag.
Unfortunately this method is too complicated for me and I don’t know which attributes still disappear like this. Otherwise I would have submitted a correction suggestion here.
Thanks for your help.
My current workaround is:
@
page.headerData.30 = TEXT
page.headerData.30.value = <script src="/fileadmin/a2hs/a2hs.js" defer></script>@
Translated with www.DeepL.com/Translator (free version)