Project

General

Profile

Actions

Feature #86962

closed

Asset pipeline: Only include assets for rendered content elements

Added by Soren Malling about 6 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2018-11-21
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Inspired by my teachings after working a bit with Ruby on Rails and the keynote as T3CON18 about speed I would like to present a feature on Asset pipeline for rendered content element.

The idea/concept is as so:

Given the tt_content elements that are being rendered, the TYPO3 rendering engine can include only assets (css/js) that are related to the content element or plugin.

For example. Here is a number of content element in colPos = 0. The idea is not limited to a single colPos, but let's keep it simple :)

[CType: text]
[CType: image]
[CType: Plugin -> Extbase plugin]
[CType: menu_sitemap]

Giving a path configuration similar to how content elements are given a path to it's HTML files

lib.assetPipeline {
  css.10 = EXT:awesomesite/Resources/Public/Assets/Css/Component/
}

The rendering will look at the rendered CType and look for EXT:awesomesite/Resources/Public/Assets/Css/Component/[CType].css to include into the pageGenerators includeCSS part. If you enable concate and compress css you will have a CSS file build for the content of that site and no bloated CSS/JS stuff.

I created a POC for extbase related rendering. Add this code block to the ActionController -> renderAssetsForRequest() method

        $assetFile = GeneralUtility::getFileAbsFileName('EXT:' . $this->getControllerContext()->getRequest()->getControllerExtensionKey() . '/Resources/Public/Assets/Css/' . $this->getControllerContext()->getRequest()->getControllerName() . '.css');

    if ($assetFile !== '') {
        $file = PathUtility::stripPathSitePrefix($assetFile);
        $pageRenderer->addCssFile(
            $file
        );
    }

The goal of this feature is to bring down the actual bytes being sent and served on each page load.

Cons

Given the dynamic combinations of content this will create a larger number of files than usual

Actions

Also available in: Atom PDF