[TASK] Exclude central Modernizr from concatenation 80/24880/2
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 17 Oct 2013 20:30:29 +0000 (22:30 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 17 Oct 2013 21:28:39 +0000 (23:28 +0200)
Modernizr is added to every "page" in the backend
as a default in DocumentTemplate. By default all JS
gets merged. Thus Modernizr is added to multiple
files.

Reduce the size of JS-files and allow browsers to
take advantage of reusing that code by having this
library as a separate part.

Change-Id: If18ca423ac3b4b1347c1319189d0feb019f37b7f
Resolves: #52931
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/24880
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/backend/Classes/Template/DocumentTemplate.php

index e241066..8557789 100644 (file)
@@ -260,6 +260,14 @@ class DocumentTemplate {
         * @var array
         */
        protected $jsFiles = array(
+       );
+
+       /**
+        * JavaScript files loaded for every page in the Backend, but explicitly excluded from concatenation (useful for libraries etc.)
+        *
+        * @var array
+        */
+       protected $jsFilesNoConcatenation = array(
                'modernizr' => 'contrib/modernizr/modernizr.min.js'
        );
 
@@ -412,6 +420,17 @@ class DocumentTemplate {
                        $this->pageRenderer->enableCompressCss();
                        $this->pageRenderer->enableCompressJavascript();
                        // Add all JavaScript files defined in $this->jsFiles to the PageRenderer
+                       foreach ($this->jsFilesNoConcatenation as $file) {
+                               $this->pageRenderer->addJsFile(
+                                       $GLOBALS['BACK_PATH'] . $file,
+                                       'text/javascript',
+                                       TRUE,
+                                       FALSE,
+                                       '',
+                                       TRUE
+                               );
+                       }
+                       // Add all JavaScript files defined in $this->jsFiles to the PageRenderer
                        foreach ($this->jsFiles as $file) {
                                $this->pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . $file);
                        }
@@ -2089,4 +2108,4 @@ class DocumentTemplate {
 }
 
 
-?>
\ No newline at end of file
+?>