diff --git a/typo3/sysext/core/Classes/Page/AssetCollector.php b/typo3/sysext/core/Classes/Page/AssetCollector.php index c87f539dc0b30dd03b2f698c5a2c45f0cedc2f1b..2ffc17be67826ee2d182a193693144b727dfdd65 100644 --- a/typo3/sysext/core/Classes/Page/AssetCollector.php +++ b/typo3/sysext/core/Classes/Page/AssetCollector.php @@ -65,6 +65,13 @@ class AssetCollector implements SingletonInterface */ protected $media = []; + /** + * @param string $identifier + * @param string $source URI to JavaScript file (allows EXT: syntax) + * @param array $attributes additional HTML <script> tag attributes + * @param array $options ['priority' => true] means rendering before other tags + * @return AssetCollector + */ public function addJavaScript(string $identifier, string $source, array $attributes = [], array $options = []): self { $existingAttributes = $this->javaScripts[$identifier]['attributes'] ?? []; @@ -79,6 +86,13 @@ class AssetCollector implements SingletonInterface return $this; } + /** + * @param string $identifier + * @param string $source JavaScript code + * @param array $attributes additional HTML <script> tag attributes + * @param array $options ['priority' => true] means rendering before other tags + * @return AssetCollector + */ public function addInlineJavaScript(string $identifier, string $source, array $attributes = [], array $options = []): self { $existingAttributes = $this->inlineJavaScripts[$identifier]['attributes'] ?? []; @@ -93,6 +107,13 @@ class AssetCollector implements SingletonInterface return $this; } + /** + * @param string $identifier + * @param string $source URI to stylesheet file (allows EXT: syntax) + * @param array $attributes additional HTML <link> tag attributes + * @param array $options ['priority' => true] means rendering before other tags + * @return AssetCollector + */ public function addStyleSheet(string $identifier, string $source, array $attributes = [], array $options = []): self { $existingAttributes = $this->styleSheets[$identifier]['attributes'] ?? []; @@ -107,6 +128,13 @@ class AssetCollector implements SingletonInterface return $this; } + /** + * @param string $identifier + * @param string $source stylesheet code + * @param array $attributes additional HTML <link> tag attributes + * @param array $options ['priority' => true] means rendering before other tags + * @return AssetCollector + */ public function addInlineStyleSheet(string $identifier, string $source, array $attributes = [], array $options = []): self { $existingAttributes = $this->inlineStyleSheets[$identifier]['attributes'] ?? []; diff --git a/typo3/sysext/core/Documentation/Changelog/10.3/Feature-90522-IntroduceAssetCollector.rst b/typo3/sysext/core/Documentation/Changelog/10.3/Feature-90522-IntroduceAssetCollector.rst index 43fcb7539d04f7335e587d16cf99996d068e9502..8431547d2c3fe2dfdccaa4a5967d87f8624b7099 100644 --- a/typo3/sysext/core/Documentation/Changelog/10.3/Feature-90522-IntroduceAssetCollector.rst +++ b/typo3/sysext/core/Documentation/Changelog/10.3/Feature-90522-IntroduceAssetCollector.rst @@ -64,6 +64,39 @@ There are also two new ViewHelpers, the :html:`<f:asset.css>` and the - :html:`< alert('hello world'); </f:asset.script> +Considerations +-------------- + +Currently, assets registered with the AssetCollector are not included in callbacks of these hooks: + +- :php:`$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler']` +- :php:`$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler']` +- :php:`$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssConcatenateHandler']` +- :php:`$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsConcatenateHandler']` + +Currently, CSS and JavaScript registered with the AssetCollector will always be rendered after their +PageRenderer counterparts. The order is: + +- :html:`<head>` +- :ts:`page.includeJSLibs.forceOnTop` +- :ts:`page.includeJSLibs` +- :ts:`page.includeJS.forceOnTop` +- :ts:`page.includeJS` +- :php:`AssetCollector::addJavaScript()` with 'priority' +- :ts:`page.jsInline` +- :php:`AssetCollector::addInlineJavaScript()` with 'priority' +- :html:`</head>` + +- :ts:`page.includeJSFooterlibs.forceOnTop` +- :ts:`page.includeJSFooterlibs` +- :ts:`page.includeJSFooter.forceOnTop` +- :ts:`page.includeJSFooter` +- :php:`AssetCollector::addJavaScript()` +- :ts:`page.jsFooterInline` +- :php:`AssetCollector::addInlineJavaScript()` + +Currently, JavaScript registered with AssetCollector is not affected by +:ts:`config.moveJsFromHeaderToFooter`. Examples --------