Bug #53123

Is compressing external JS and CSS files necessary by default?

Added by Artur Cichosz almost 6 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Could have
Assignee:
Category:
Frontend
Target version:
-
Start date:
2013-10-25
Due date:
% Done:

100%

TYPO3 Version:
6.0
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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


Related issues

Related to TYPO3 Core - Bug #29695: t3lib_Compressor fails with external files Closed 2011-09-12

Associated revisions

Revision 8306763f (diff)
Added by Benjamin Kott 10 months ago

[BUGFIX] Disable file compression for external urls in js and css includes

Resolves: #53123
Releases: master, 8.7
Change-Id: I8030e434a27ae2f2c5934706eec6f64e64e31cd3
Reviewed-on: https://review.typo3.org/58867
Tested-by: TYPO3com <>
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>
Reviewed-by: Josef Glatz <>
Reviewed-by: Daniel Goerz <>
Reviewed-by: Willi Wehmeier <>
Reviewed-by: Jörg Bösche <>
Reviewed-by: Jan Helke <>
Tested-by: Jan Helke <>

History

#1 Updated by Philipp Gampe almost 6 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.

#2 Updated by Alexander Opitz over 5 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?

#3 Updated by Artur Cichosz over 5 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.

#4 Updated by Alexander Opitz over 5 years ago

  • Status changed from Needs Feedback to New

Ok, so I misread it yesterday.

#5 Updated by Riccardo De Contardi almost 4 years ago

  • Category set to Frontend

#6 Updated by Gerrit Code Review 11 months 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

#7 Updated by Gerrit Code Review 11 months 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

#8 Updated by Benjamin Kott 10 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#9 Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF