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