From c0383127fcd35b389a2e86f3d45d213ea91ed9bb Mon Sep 17 00:00:00 2001 From: Steffen Gebert <steffen.gebert@typo3.org> Date: Tue, 25 Oct 2011 01:01:56 +0200 Subject: [PATCH] [TASK] Documentation of compressJs feature The documentation (NEWS.txt and TypoScript completion) does not correctly explain the feature set of config.compressJs. Instead of the advertised minification (stripping white-spaces), it only applies GZIP compression (which then requires compressionLevel to be enabled in the Install Tool). This is a difference to config.compressCss, which does such a minification. Additionally, .htaccess lacks hints about the gzip rules, which now also apply to the Frontend. Change-Id: I30929ee70d0ab5fd6db74717889af6104c12e23d Resolves: #31251 Releases: 4.6 Reviewed-on: http://review.typo3.org/6277 Reviewed-by: Xavier Perseguers Tested-by: Xavier Perseguers Reviewed-by: Philipp Gampe Tested-by: Philipp Gampe Reviewed-by: Jigal van Hemert Tested-by: Jigal van Hemert --- NEWS.txt | 51 ++++++++++++++--------- _.htaccess | 6 ++- typo3/sysext/t3editor/res/tsref/tsref.xml | 6 ++- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index f6b502c87d39..b75e4865e712 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -415,36 +415,47 @@ Caching Framework when needed. * Compression and concatenation of CSS and JavaScript files -New built-in minification routines can now be used with config.compressCss and -config.compressJs to reduce the file size of all files configured in -page.includeCSS and page.includeJS. Single files can be excluded from -compression using the new option disableCompression. Additionally, files can -be concatenated into a single file using config.concatenateCss and -config.concatenateJs. Please note that there is only limited support for -@charset, @import and @namespace statements in concatenated CSS files. +Built-in minification routines can now be used with config.compressCss to +reduce the size of all files configured in page.includeCSS. +With compressCss and/or compressJs enabled, CSS files and JavaScript files +(included using page.includeJS) can be saved and delivered with GZIP +compression in the Frontend, assuming $TYPO3_CONF_VARS['FE'] +['compressionLevel'] is set. +Similar to $TYPO3_CONF_VARS['BE']['compressionLevel'] (available since TYPO3 +4.4), the following options must be set in .htaccess: + + <FilesMatch "\.js\.gzip$"> + AddType "text/javascript" .gzip + </FilesMatch> + <FilesMatch "\.css\.gzip$"> + AddType "text/css" .gzip + </FilesMatch> + AddEncoding gzip .gzip + +Single files can be excluded from compression using the new option +disableCompression. Additionally, files can be concatenated into a single file +using config.concatenateCss and config.concatenateJs. Please note that there is +only limited support for @charset, @import and @namespace statements in +concatenated CSS files. Together with config.removeDefaultJS = external -these routines will significantly lower web site traffic. +these routines will significantly increase your website speed! -Furthermore, if compressCss/compressJs is enabled, -$TYPO3_CONF_VARS['FE']['compressionLevel'] now also affects CSS and JS files in -frontend and applies GZIP compression. This requires the same options as for -$TYPO3_CONF_VARS['BE']['compressionLevel'] to be set in .htaccess. - -You may disable compression and/or concatenation on the PAGE object. Example: +You may disable compression and/or concatenation for CSS and JavaScript included +with the PAGE object. Example: page.includeJSlibs { - jquery = http://code.jquery.com/jquery-1.6.1.min.js - jquery.external = 1 - jquery.disableCompression = 1 - jquery.excludeFromConcatenation = 1 + jquery = http://code.jquery.com/jquery-1.6.1.min.js + jquery.external = 1 + jquery.disableCompression = 1 + jquery.excludeFromConcatenation = 1 } The same options apply for includeCSS. Please note that compression and concatenation apply for external resources as -well. But if activated, they will be dynamically retrieved to allow requested -processing and will be served locally. +well. If activated, external resources will be dynamically retrieved, processed, +and served locally. \ No newline at end of file diff --git a/_.htaccess b/_.htaccess index 899c0d2798f0..3c623c2b9283 100644 --- a/_.htaccess +++ b/_.htaccess @@ -37,8 +37,10 @@ # Compressing resource files will save bandwidth and so improve loading speed especially for users # with slower internet connections. TYPO3 can compress the .js and .css files for you. -# 1) Uncomment the following lines and -# 2) Set $TYPO3_CONF_VARS['BE']['compressionLevel'] = '9' +# *) Uncomment the following lines and +# *) Set $TYPO3_CONF_VARS['BE']['compressionLevel'] = '9' for the Backend +# *) Set $TYPO3_CONF_VARS['FE']['compressionLevel'] = '9' together with the TypoScript properties +# config.compressJs and config.compressCss for GZIP compression of Frontend JS and CSS files. #<FilesMatch "\.js\.gzip$"> # AddType "text/javascript" .gzip diff --git a/typo3/sysext/t3editor/res/tsref/tsref.xml b/typo3/sysext/t3editor/res/tsref/tsref.xml index 9f9dd37af187..dee1db7b841c 100644 --- a/typo3/sysext/t3editor/res/tsref/tsref.xml +++ b/typo3/sysext/t3editor/res/tsref/tsref.xml @@ -857,9 +857,11 @@ config.removeDefaultJS = 1]]></description> <default><![CDATA[false]]></default> </property> <property name="compressJs" type="boolean"> - <description><![CDATA[If set, inline JavaScript and external JavaScript files will be minified and compressed. + <description><![CDATA[Enabling this option together with $TYPO3_CONF_VARS['FE']['compressionLevel'] in the Install Tool delivers Frontend JavaScript files using GZIP compression. -Minification will remove all excess space. The more significant compression step (using Gzip compression) requires $TYPO3_CONF_VARS['FE']['compressionLevel'] to be enabled in the Install Tool together with the gzip-related compressionLevel options in .htaccess, as otherwise the files will not be readable by the user agent. +This can significantly reduce file sizes of linked JavaScript files and thus decrease loading times. + +Please not that this requires .htaccess to be adjusted, as otherwise the files will not be readable by the user agent. Please see the description of $TYPO3_CONF_VARS['FE']['compressionLevel'] in the Install Tool. Example: -- GitLab