Bug #53123
closedIs compressing external JS and CSS files necessary by default?
100%
Description
I didn't make use of JS / CSS compressor to much, so I didn't notice the problem until now, where I have some external CSS/JS files included and compressor activated at the same time.
The compressor tries to compress the external file and store it locally but fails to do so properly.
I get the following Error in the frontend:
Warning: filemtime(): stat failed for /srv/.../trunk/typo3/http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css in /srv/www/htdocs/typo3_src/6.0.10/typo3/sysext/core/Classes/Resource/ResourceCompressor.php on line 367
Anyway I do not think it's necessary to compress external files at all, since it is against the general idea of using CDN networks.
Of course there is the possibility to switch off compression for a file explicitly using includeJS.[key].disableCompression.
But I think it would be better to make "not compressing" external files the default behavior and to give the posibility to enable it explicitly if desired.
In my case I extended the class \TYPO3\CMS\Frontend\Page\PageGenerator and made some changes, where includeJS, includeCSS, includeJSFooter, includeJSLibs and includeJSLibsFooter are processed, making each time a change similar to the following:
/** * Modified by Quintinity - Start * prevent from compressing external files */ $pageRenderer->addCssFile($ss, $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['alternate'] ? 'alternate stylesheet' : 'stylesheet', $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] : 'all', $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] : '', empty($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['disableCompression']) && empty($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['external']), $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE, $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['allWrap'], $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['excludeFromConcatenation'] ? TRUE : FALSE); // Modified By Quintinity - Stop
Updated by Philipp Gampe about 11 years ago
- Status changed from New to Needs Feedback
I agree with you. Browsers will cache contents (idea of CDN) and therefor it does not make any sense to compress a file locally*.
- It could make sense on mobile optimized sites that want to save open TCP connections, however I do not think that this wins more performance that a cached file from a CDN.
Updated by Alexander Opitz almost 11 years ago
- Priority changed from -- undefined -- to Could have
- Target version deleted (
6.0.9)
In http://wiki.typo3.org/TYPO3_4.6#JS.2FCSS_Compression is described how to exclude such files. Does this help you?
Updated by Artur Cichosz almost 11 years ago
I know this already, see "Of course there is the possibility to switch off compression for a file explicitly using includeJS.[key].disableCompression.".
I do only think it could be better to change the default behaviour.
Updated by Alexander Opitz over 10 years ago
- Status changed from Needs Feedback to New
Ok, so I misread it yesterday.
Updated by Gerrit Code Review about 6 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58867
Updated by Gerrit Code Review about 6 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58867
Updated by Benjamin Kott almost 6 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 8306763fafd4afa99fe4ca1c17f0c076ee93b54c.
Updated by Georg Ringer over 4 years ago
- Related to Bug #87861: config.compressCss prevents inclusion of external files added