Skip to content

Commit

Permalink
feat: only load RockFrontend.js if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jul 4, 2023
1 parent 25364be commit f62ec7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
5 changes: 1 addition & 4 deletions RockFrontend.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 13 additions & 10 deletions RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,15 @@ function (HookEvent $event) {

// load RockFrontend frontend js file
$file = __DIR__ . "/RockFrontend.js";
if ($this->wire->config->debug) {
// load the non-minified script
$this->scripts('rockfrontend')->add($file, "defer");
// when logged in as superuser we make sure to create the minified
// file even if the non-minified version is used.
if ($this->wire->user->isSuperuser()) $this->minifyFile($file);
} else $this->scripts('rockfrontend')->add($this->minifyFile($file), "defer");
if ($this->isEnabled('RockFrontend.js')) {
if ($this->wire->config->debug) {
// load the non-minified script
$this->scripts('rockfrontend')->add($file, "defer");
// when logged in as superuser we make sure to create the minified
// file even if the non-minified version is used.
if ($this->wire->user->isSuperuser()) $this->minifyFile($file);
} else $this->scripts('rockfrontend')->add($this->minifyFile($file), "defer");
}

// load alfred?
if ($this->loadAlfred()) {
Expand Down Expand Up @@ -2082,9 +2084,10 @@ private function configSettings($inputfields)
$f = $this->wire->modules->get('InputfieldCheckboxes');
$f->name = 'features';
$f->label = "Features";
$f->addOption('postCSS', 'postCSS - Use the internel postCSS feature (eg to use rfGrow() syntax)');
$f->addOption('minify', 'minify - Auto-create minified CSS/JS assets ([see docs](https://github.com/baumrock/RockFrontend/wiki/Minify-Feature))');
$f->addOption('topbar', 'topbar - Show topbar (sitemap, edit page, toggle mobile preview)');
$f->addOption('RockFrontend.js', 'RockFrontend.js - Load this file on the frontend (eg to use consent tools).');
$f->addOption('postCSS', 'postCSS - Use the internel postCSS feature (eg to use rfGrow() syntax).');
$f->addOption('minify', 'minify - Auto-create minified CSS/JS assets ([see docs](https://github.com/baumrock/RockFrontend/wiki/Minify-Feature)).');
$f->addOption('topbar', 'topbar - Show topbar (sitemap, edit page, toggle mobile preview).');
$f->value = (array)$this->features;
$fs->add($f);

Expand Down

0 comments on commit f62ec7e

Please sign in to comment.