Project

General

Profile

Actions

Bug #90208

closed

includeJS + defer does not work if the ResourceCompressor has done its job

Added by C. Gogolin almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
TypoScript
Start date:
2020-01-26
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.3
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

I use Typo3 9.5.13.

According to the documentation the attribute defer is supported:

Typo3:
[[https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.0/Feature-80542-TypoScriptJavaScriptDeferAttribute.html]]

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)


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #87444: 'config.concatenateJs = 1' async feature does not workClosed2019-01-15

Actions
Actions

Also available in: Atom PDF