Review main Merged

63327[FEATURE] Introduce AssetCollector

Benni Mack CR +2 V +2 Expert +1302 −17 updated 02/26/20, 08:48

Commit message

AssetCollector is a concept to allow custom CSS/JS code,
inline or external, to be added multiple times in e.g. a Fluid
template (via <f:script> or <f:css> ViewHelpers) and only be
added once.

It considers best practices by having a "priority" flag to be either
be moved in the <head> area (for CSS useful in above-the-fold concepts)
or at the bottom of the <body> tag contents.

AssetCollector helps to work with content elements as components,
reducing effectively the amount of CSS to be loaded and also incorporates
the HTTP/2 power where it is not relevant to have all files compressed
and concatenated in one file (although this could be added later-on).

AssetCollector is implemented as singleton and should slowly replace
the various existing options in TypoScript which seem to be confusing.

AssetCollector also collects information about "imagesOnPage"
effectively taking off pressure from PageRenderer and TSFE to
store common data in FE - as this is now handled in AssetCollector,
which can be used in cached and non-cached components.

Review

  • Code review CR +2 Done
    • Susi Moog +2
    • Daniel Goerz +1
    • Georg Ringer +1
    • Daniel Gohlke +1
    • Kevin Appelt +1
  • Verified V +2 Done
    • Susi Moog +2
    • Daniel Goerz +1
    • Georg Ringer +1
    • Daniel Gohlke +1
    • Kevin Appelt +1
    • TYPO3com +1 CI

Issues 1

Files 15

Review log 5266

Show 3241 earlier messages
  1. Benni Mack uploaded patch set 1 02/19/20, 22:15

  2. TYPO3com voted on patch set 1 V -1 02/19/20, 22:28 Completed build in 13m 07s on Wed, 19 Feb, 10:28 PM Test Summary: 6 of 71920 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-331

  3. Frank Nägler commented on patch set 1 CR -1 02/21/20, 09:23

    on it
  4. Frank Nägler uploaded patch set 2 02/21/20, 13:52

  5. Frank Nägler commented on patch set 2 CR -1 02/21/20, 13:54

    still on it
  6. TYPO3com voted on patch set 2 V -1 02/21/20, 14:00 Completed build in 33s on Fri, 21 Feb, 02:00 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-402

  7. Frank Nägler uploaded patch set 3 02/21/20, 14:03

  8. Frank Nägler voted on patch set 3 CR -1 02/21/20, 14:03

  9. Frank Nägler voted on patch set 3 CR 0 02/21/20, 14:15

  10. TYPO3com voted on patch set 3 V -1 02/21/20, 14:39 Completed build in 18m 57s on Fri, 21 Feb, 02:39 PM Test Summary: 6 of 72316 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-403

  11. Frank Nägler uploaded patch set 4 02/24/20, 17:12

  12. TYPO3com voted on patch set 4 V -1 02/24/20, 17:12 Completed build in 29s on Mon, 24 Feb, 05:12 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-637

  13. Frank Nägler uploaded patch set 5 02/24/20, 17:18

  14. TYPO3com voted on patch set 5 V -1 02/24/20, 17:35 Completed build in 16m 14s on Mon, 24 Feb, 05:35 PM Test Summary: 6 of 72529 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-639

  15. Susi Moog uploaded patch set 6 02/24/20, 18:23

  16. Kevin Appelt commented on patch set 6 02/24/20, 18:31

    Is there a way to define the order of inclusion/loading? Like „load this slider lib before my slider script“ or alike?
  17. Frank Nägler commented on patch set 6 02/24/20, 18:33

    > Is there a way to define the order of inclusion/loading? Like „load this slider lib before my slider script“ or alike? Not yet, and will also not be part of this patch. But ordering service will be the next step in this area.
  18. TYPO3com voted on patch set 6 V +1 02/24/20, 18:52 Completed build in 28m 18s on Mon, 24 Feb, 06:52 PM Test Summary: 72045 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-644

  19. Frank Nägler uploaded patch set 7 02/24/20, 18:57

  20. TYPO3com voted on patch set 7 V -1 02/24/20, 19:10 Completed build in 13m 06s on Mon, 24 Feb, 07:10 PM Test Summary: 71881 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-647

  21. TYPO3com voted on patch set 7 V +1 02/24/20, 19:39 Completed build in 55m 16s on Mon, 24 Feb, 07:39 PM Test Summary: 71991 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-647

  22. Andreas Kienast commented on patch set 7 CR -1 02/24/20, 20:02

    on it

    AssetCollector.php:173 Unresolved

    I'd rename this method to "getInlineJavaScripts()" (everything else is in plural as well)
  23. Andreas Kienast commented on patch set 7 02/24/20, 20:05

    TypoScriptFrontendController.php:544 Unresolved

    Will do a proper deprecation here.
  24. Kevin Appelt commented on patch set 7 02/24/20, 20:13

    CssViewHelper.php:61

    Whats the reason to use hreflang for a stylesheet? Never have seen it before.
  25. Susi Moog commented on patch set 7 02/24/20, 20:15

    CssViewHelper.php:61 Reply

    adherence to the specification of the link tag I guess (see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
  26. Frank Nägler commented on patch set 7 02/24/20, 20:18

    CssViewHelper.php:61 Reply

    I guess this is the reason, I thought also about it, but decided to keep it, because it is valid for the <link> tag.
  27. Nikita Hovratov commented on patch set 7 02/24/20, 20:20

    Feature-90522-IntroduceAssetCollectortAndAssetRenderer.rst:55

    In this example the rel="stylesheet" attribute is missing. Or can we have this as default, if a file is supplied?
  28. Kevin Appelt commented on patch set 7 02/24/20, 20:23

    CssViewHelper.php:61 Reply Unresolved

    "This attribute (hreflang) indicates the language of the linked resource." So yes, it is valid for the link attribute, but I guess it has no meaning at all for css files. Since this is the CssViewHelper and not the LinkViewHelper, I might consider removing it - especially to avoid misuse of this viewhelper to set the hreflang.
  29. Frank Nägler commented on patch set 7 02/24/20, 20:24

    Feature-90522-IntroduceAssetCollectortAndAssetRenderer.rst:55 Reply

    Good point, but I would like to add this to the AssetRenderer not the VH
  30. David Steeb voted on patch set 7 CR +1 02/24/20, 20:40

  31. Andreas Kienast uploaded patch set 8 02/24/20, 20:40

  32. Frank Nägler commented on patch set 7 02/24/20, 20:40

    Feature-90522-IntroduceAssetCollectortAndAssetRenderer.rst:55 Reply Unresolved

    will push an update with defaults in the AssetRenderer class, after Andy has pushed.
  33. Frank Nägler uploaded patch set 9 02/24/20, 20:41

  34. Nikita Hovratov commented on patch set 9 02/24/20, 20:45

    AssetRenderer.php:39

    We can omit the text/javascript type attribute if we have html5 See: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61300
  35. Nikita Hovratov commented on patch set 9 02/24/20, 20:48

    AssetRenderer.php:39 Reply

    *As well as text/css
  36. Frank Nägler commented on patch set 9 02/24/20, 20:49

    AssetRenderer.php:39 Reply Unresolved

    Agree, but the context is not clear at this moment. I would keep it, for now, because the patch must go in until tomorrow. I am fine to change this or find a solution for the 10.4 release.
  37. TYPO3com voted on patch set 8 V -1 02/24/20, 20:56 Completed build in 16m 12s on Mon, 24 Feb, 08:56 PM Test Summary: 71997 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-652

  38. Nikita Hovratov commented on patch set 9 02/24/20, 21:01

    ScriptViewHelper.php:29

    should be src instead of href in the example
  39. Nikita Hovratov commented on patch set 9 02/24/20, 21:07

    > Patch Set 8: Verified-1 > > Completed build in 16m 12s on Mon, 24 Feb, 08:56 PM > Test Summary: 71997 passed > Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-652 Keywords are missing in the Deprecation rst :P
  40. Andreas Kienast uploaded patch set 10 02/24/20, 21:07

  41. Nikita Hovratov commented on patch set 10 02/24/20, 21:10

    ScriptViewHelper.php:29 Reply

    Done
  1. TYPO3com voted on patch set 9 V -1 02/24/20, 21:17 Completed build in 31m 17s on Mon, 24 Feb, 09:17 PM Test Summary: 71997 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-653

  2. Daniel Goerz commented on patch set 10 V -1 02/24/20, 21:26

    Examples state that paths starting with 'EXT:' are resolved for JS as well as CSS files which is not the case for either. IMO the AssetCollector should do this only once for the "final" source for any given identifier. This would mean either let the first occurrence of any identifier win (currently the last one wins) and resolve immediately or resolve before returning in the getter.
  3. Daniel Gohlke commented on patch set 10 02/24/20, 21:28

    I like the idea of the AssetCollector.

    AssetCollector.php:62 Unresolved

    Is there a reason why StyleSheets use different names for the propterties and the functions Wouldn't it be better to also call $styleSheets and $inlineStyleSheets similar to JavaScript. The function names also differ for the CSS information. In \TYPO3\CMS\Core\Page\AssetRenderer the methods are then called renderStyleSheets and renderInlineStyleSheets. For the JS it should be named the same in the classes, right? In my opinion, would simplify the use.
  4. Frank Nägler commented on patch set 10 02/24/20, 21:29

    > Patch Set 10: Verified-1 > > Examples state that paths starting with 'EXT:' are resolved for JS as well as CSS files which is not the case for either. IMO the AssetCollector should do this only once for the "final" source for any given identifier. This would mean either let the first occurrence of any identifier win (currently the last one wins) and resolve immediately or resolve before returning in the getter. The AssetRenderer take care of the EXT: path rsolving, which IMHO the correct place. Anything before rendering is mangagement/registry scope.
  5. Daniel Goerz commented on patch set 10 02/24/20, 21:35

    > Patch Set 10: > > > Patch Set 10: Verified-1 > > > > Examples state that paths starting with 'EXT:' are resolved for JS as well as CSS files which is not the case for either. IMO the AssetCollector should do this only once for the "final" source for any given identifier. This would mean either let the first occurrence of any identifier win (currently the last one wins) and resolve immediately or resolve before returning in the getter. > > The AssetRenderer take care of the EXT: path rsolving, which IMHO the correct place. > Anything before rendering is mangagement/registry scope. Ah, yes, I just saw that, thats fine, too. Let me find out why this is not working for me, I have <link href="EXT:my_ext/Resources/Public/Css/foo.css" rel="stylesheet" type="text/css" > in my HTML.
  6. Daniel Goerz commented on patch set 10 CR -1 02/24/20, 21:45

    on it
  7. TYPO3com voted on patch set 10 V +1 02/24/20, 21:49 Completed build in 30m 44s on Mon, 24 Feb, 09:49 PM Test Summary: 71997 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-656

  8. Daniel Goerz uploaded patch set 11 02/24/20, 21:56

  9. Daniel Goerz voted on patch set 11 V +1 CR +1 02/24/20, 21:57

  10. Daniel Gohlke uploaded patch set 12 02/24/20, 22:27

  11. Daniel Gohlke voted on patch set 12 CR +1 02/24/20, 22:28

  12. TYPO3com voted on patch set 11 V +1 02/24/20, 22:46 Completed build in 40m 23s on Mon, 24 Feb, 10:45 PM Test Summary: 71997 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-665

  13. TYPO3com voted on patch set 12 V +1 02/24/20, 22:52 Completed build in 15m 39s on Mon, 24 Feb, 10:51 PM Test Summary: 71997 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-666

  14. Georg Ringer voted on patch set 12 CR +1 02/24/20, 22:52

  15. Daniel Goerz commented on patch set 12 CR -1 02/24/20, 22:57

    AssetCollector.php:46

    jasaScripts

    Feature-90522-IntroduceAssetCollector.rst:48

    This is now outdated
  16. Daniel Goerz uploaded patch set 13 02/24/20, 23:08

  17. Daniel Goerz voted on patch set 13 V +1 CR +1 02/24/20, 23:09

  18. Georg Ringer voted on patch set 13 V +1 CR +1 02/24/20, 23:23

  19. TYPO3com voted on patch set 13 V +1 02/24/20, 23:41 Completed build in 27m 47s on Mon, 24 Feb, 11:41 PM Test Summary: 71997 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-668

  20. Kevin Appelt voted on patch set 13 V +1 CR +1 02/25/20, 06:00

  21. Daniel Gohlke commented on patch set 13 V +1 CR +1 02/25/20, 06:03

    AssetCollector.php:46 Reply

    Done

    Feature-90522-IntroduceAssetCollector.rst:48 Reply

    Ack
  22. Susi Moog voted on patch set 13 V +2 CR +2 02/25/20, 06:05

  23. Susi Moog merged patch set 14 02/25/20, 06:05

  24. Oli Bartsch commented on patch set 14 02/25/20, 06:14

    Great work! Little bit to late but just one question regarding the fallback behavior in the ViewHelpers if no file is given (which means render inline).

    CssViewHelper.php:97 Unresolved

    Should we check if this isn’t null?

    ScriptViewHelper.php:93 Unresolved

    Same here?
  25. Oli Bartsch commented on patch set 14 02/26/20, 08:48

    > Patch Set 14: > > (2 comments) > > Great work! Little bit to late but just one question regarding the fallback behavior in the ViewHelpers if no file is given (which means render inline). I created a patch for this: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63437