79144[BUGFIX] Determine async property by section
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 1
Review log 56
-
Johannes Nielsen uploaded patch set 1 05/25/23, 08:09
-
core-ci voted on patch set 1 V +1 05/25/23, 08:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/42015
-
Stefan Bürk commented on patch set 1 CR -1 06/15/23, 12:31
If this patch is really valid (see the in code comment), it should add tests to showcase and guard this. TBH not verified and currently not have the time to verify it. Maybe someone else have time for it. Just done a pure code walk-through.ResourceCompressor.php:173This section split does not make much sense. 1. files to be concenatated into one file are of the same section with not used `moveJsFromHeaderToFooter` setting 2. files to be concenated into one file are from two sections if `moveJsFromHeaderToFooter` ending in one file. The current logic here is, that at least "one" file must have "async" set, and if one has set all files have it set. Otherwise async is thrown away for the resulting concenated file, which is okay. That means, that your code does not make much sense. At least it does not make a difference. However, not tested yet - such from reading the code. Are you sure, you do not have https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Config/Index.html#movejsfromheadertofooter configured/set to true ? -
Johannes Nielsen commented on patch set 1 06/15/23, 13:35
ResourceCompressor.php:173ReplyExactly: Files to be concatenated into one file are of the same section, if `moveJsFromHeaderToFooter` is disabled. However, at this point in the for-loop the old logic makes no distinction between sections. That means that if _any_ file does not have `async=1` set, then _none_ of the concatenated files will have it set, either. As the issue states, imagine this TS setup: ``` config.concatenateJs = 1 config.moveJsFromHeaderToFooter = 0 page { includeJS { headerJSfile = EXT:example/Resources/Public/JavaScript/headerJSfile.js headerJSfile.async = 1 } includeJSFooter { footerJSfile = EXT:example/Resources/Public/JavaScript/footerJSfile.js } } ``` This would lead to two concatenated JS files being created, one being included in the head, the other in the body tag. _None_ of these files would have the async attribute set, even though there is no reason why the one in the head should not have it set. The new logic does make a difference in that regard. With the new logic, the JS file in the head would have the async attribute set. Likewise, if `footerJSfile` was async, so would the concatenated file in the body, and if all files were async, then so would all concatenated ones. As for your second remark: I will check. IIRC all files a pushed into includeJSFooter, when `moveJsFromHeaderToFooter` is enabled, but I will check that, of course. -
Johannes Nielsen commented on patch set 1 CR -1 06/15/23, 14:06
ResourceCompressor.php:173Reply UnresolvedSetting `moveJsFromHeaderToFooter` makes no difference. Indeed you are correct, the error seems to be much earlier in PageRenderer, where only `$this->jsFiles` is set, but not `$this->jsFooterFiles`. So I believe that section split should happen there and the ResourceCompressor should not worry about sections at all. -
Johannes Nielsen abandoned the change 06/15/23, 14:31
The real core of the issue seems to lie in the PageRenderer which does not properly split JS files that go in the head and those that go in the body tag. More investigation is needed, but the ResourceCompressor does not seem to be the actual culprit.