1
0
mirror of https://github.com/flarum/core.git synced 2025-07-26 03:01:22 +02:00

Minify each JS file individually, caching the result

This means that the expensive minification process will only be run for a file if it hasn't before. Greatly speeds up extension enabling/disabling.

Also:
- Don't check file last modification times in production for a bit of extra perf.
- Only flush CSS when theme settings are changed. This speeds up the page reload a bit.
This commit is contained in:
Toby Zerner
2015-10-09 01:52:51 +10:30
parent 18def302d6
commit 6f1c46819e
10 changed files with 149 additions and 62 deletions

View File

@@ -11,10 +11,12 @@
namespace Flarum\Forum\Controller;
use Flarum\Api\Client;
use Flarum\Formatter\Formatter;
use Flarum\Foundation\Application;
use Flarum\Settings\SettingsRepository;
use Flarum\Locale\LocaleManager;
use Flarum\Http\Controller\AbstractClientController;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Contracts\Events\Dispatcher;
class ClientController extends AbstractClientController
@@ -29,6 +31,11 @@ class ClientController extends AbstractClientController
*/
protected $translationKeys = ['core.forum', 'core.lib'];
/**
* @var Formatter
*/
protected $formatter;
/**
* {@inheritdoc}
*/
@@ -37,11 +44,14 @@ class ClientController extends AbstractClientController
Client $api,
LocaleManager $locales,
SettingsRepository $settings,
Dispatcher $events
Dispatcher $events,
Repository $cache,
Formatter $formatter
) {
parent::__construct($app, $api, $locales, $settings, $events);
parent::__construct($app, $api, $locales, $settings, $events, $cache);
$this->layout = __DIR__.'/../../../views/forum.blade.php';
$this->formatter = $formatter;
}
/**
@@ -52,7 +62,7 @@ class ClientController extends AbstractClientController
$assets = parent::getAssets();
$assets->addJs(function () {
return $this->app->make('flarum.formatter')->getJs();
return $this->formatter->getJs();
});
return $assets;