From fc6921103e839b5fc487bbd38a562bee95489f8b Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 18 Mar 2020 20:20:43 +0100 Subject: [PATCH] The Config::DEBUG flag toggles the min files (#502). --- application/helpers/asset_helper.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/application/helpers/asset_helper.php b/application/helpers/asset_helper.php index fb565dd7..de514082 100644 --- a/application/helpers/asset_helper.php +++ b/application/helpers/asset_helper.php @@ -28,5 +28,15 @@ function asset_url($uri = '', $protocol = NULL) $cache_busting_token = ! Config::DEBUG_MODE ? '?' . $ci->config->item('cache_busting_token') : ''; + if (strpos(basename($uri), '.js') !== FALSE && strpos(basename($uri), '.min.js') === FALSE && ! Config::DEBUG_MODE) + { + $uri = str_replace('.js', '.min.js', $uri); + } + + if (strpos(basename($uri), '.css') !== FALSE && strpos(basename($uri), '.min.css') === FALSE && ! Config::DEBUG_MODE) + { + $uri = str_replace('.css', '.min.css', $uri); + } + return base_url($uri . $cache_busting_token, $protocol); }