CoreResources - Look fo non-mini js file when in debug mode
authorColeman Watts <coleman@civicrm.org>
Mon, 7 Apr 2014 18:23:08 +0000 (14:23 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 7 Apr 2014 18:23:08 +0000 (14:23 -0400)
CRM/Core/Resources.php

index 04d2ae505d5237db2602ce15b8a4e99af5c2a2ee..c46b955e7d1111cdcd0401269ff7df3cd53c2c56 100644 (file)
@@ -159,6 +159,13 @@ class CRM_Core_Resources {
     if ($translate) {
       $this->translateScript($ext, $file);
     }
+    // Look for non-minified version if we are in debug mode
+    if (CRM_Core_Config::singleton()->debug && strpos($file, '.min.js') !== FALSE) {
+      $nonMiniFile = str_replace('.min.js', '.js', $file);
+      if ($this->getPath($ext, $nonMiniFile)) {
+        $file = $nonMiniFile;
+      }
+    }
     return $this->addScriptUrl($this->getUrl($ext, $file, TRUE), $weight, $region);
   }
 
@@ -563,6 +570,7 @@ class CRM_Core_Resources {
   public function coreResourceList() {
     $config = CRM_Core_Config::singleton();
     // Use minified files for production, uncompressed in debug mode
+    // Note, $this->addScriptFile would automatically search for the non-minified file in debug mode but this is probably faster
     $min = $config->debug ? '' : '.min';
 
     // Scripts needed by everyone, everywhere