J4 Issue ?
avatar brianteeman
brianteeman
14 Aug 2018

Normally when joomla debug mode is on we use the non minified assets

But that is not true for "some" of the js in the system/webcomponents/js and vendor/webcomponents/js folders

Screenshot of global config showing just some are non minified

chrome_2018-08-14_13-58-30

avatar brianteeman brianteeman - open - 14 Aug 2018
avatar joomla-cms-bot joomla-cms-bot - change - 14 Aug 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Aug 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Aug 2018
Status New Discussion
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Aug 2018
Category JavaScript
avatar dgrammatiko
dgrammatiko - comment - 14 Aug 2018

@brianteeman check for example rules.php under layouts/joomla/form:

HTMLHelper::_('webcomponent', 'system/webcomponents/joomla-field-permissions.min.js', ['version' => 'auto', 'relative' => true]);
HTMLHelper::_('webcomponent', 'vendor/joomla-custom-elements/joomla-tab.min.js', ['relative' => true, 'version' => 'auto']);

there is a missing flag 'detectDebug' => true

avatar brianteeman
brianteeman - comment - 14 Aug 2018

Thanks for the pointer. I can fix that on the train to the presentation

avatar brianteeman
brianteeman - comment - 14 Aug 2018

or maybe not

A quick search shows these three variations - is there some logic behind the differences?


HTMLHelper::_('webcomponent', 'vendor/joomla-custom-elements/joomla-alert.min.js', ['relative' => true, 'version' => 'auto']);
HTMLHelper::_('webcomponent', 'vendor/joomla-custom-elements/joomla-alert.min.js', ['relative' => true, 'version' => 'auto', 'detectBrowser' => false, 'detectDebug' => false]);
HTMLHelper::_('webcomponent', 'system/webcomponents/joomla-field-media.min.js', ['relative' => true, 'version' => 'auto', 'detectBrowser' => false, 'detectDebug' => true]);

avatar dgrammatiko
dgrammatiko - comment - 14 Aug 2018

Tha last one should be the norm...

avatar Bakual
Bakual - comment - 14 Aug 2018

Would it make sense to add those as default values to the HtmlHelper method? If not needed it could be explicitely disabled instead of us having to explicitely add it everywhere.

avatar brianteeman
brianteeman - comment - 14 Aug 2018

Would save a massive search and replace and ofc no guarantee it wouldn't happen again

avatar Bakual
Bakual - comment - 14 Aug 2018

On a fast glance there is actually a default defineed. It's just false. If we change that to true we could save quite a bit of code. Also the relative and detectBrowser would already be covered.
See

$options['relative'] ?? true,
$options['detectBrowser'] ?? false,
$options['detectDebug'] ?? false

avatar C-Lodder
C-Lodder - comment - 14 Aug 2018

Is detectDebug the boolean that will ensure the uncompressed version of the file is loaded when debug mode is enabled?

avatar brianteeman
brianteeman - comment - 14 Aug 2018

yes

avatar C-Lodder
C-Lodder - comment - 14 Aug 2018

Why does that need to be a function arguement?

avatar dgrammatiko
dgrammatiko - comment - 14 Aug 2018

it's there for B/C

avatar mbabker
mbabker - comment - 14 Aug 2018

It has use in some edge cases. I have extensions where I'm pulling a vendor CSS or JS file and not including both a minified and unminified version of it, so I can tell Joomla to save a few CPU cycles and skip deciding if debug mode is enabled and trying to scan the filesystem for variants that will never exist (same for the detectBrowser option).

avatar Bakual
Bakual - comment - 14 Aug 2018

it's there for B/C

B/C for a method which is completely new in 4.0.0? Probably not.

In the other similar methods for scripts and stylesheets, detectDebug already defauls to true, so I'd say it's save to change that behavior for the new method so it follows the other behaviors.

See #21617

avatar dgrammatiko
dgrammatiko - comment - 14 Aug 2018

@Bakual if you are about to make this change for the webcomponents why don't you also change it for script and stylesheet, eg make the relative true, the version auto, the detectBrowser false and the detectDebug true as default for all of them?
That will save as a lot of repeated flags and still allow users to use the other settings if they want to.

Sensible defaults make sense to me

avatar Bakual
Bakual - comment - 14 Aug 2018

From what I saw, detectBrowser defaults already to false in all those methods.
version defaults to empty (false) in all cases. So that's consistent as well.
The only thing different is the relative one, and that one I didn't change in the other methods because it would be a B/C break for those existing methods.

I wanted to keep my PR as a no-brainer, changing one simple thing which doesn't break anything ?

avatar brianteeman brianteeman - change - 15 Aug 2018
Labels Added: J4 Issue
avatar brianteeman brianteeman - labeled - 15 Aug 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Aug 2018
Build staging 4.0-dev
avatar brianteeman
brianteeman - comment - 13 Sep 2018

closed see #22158

avatar brianteeman brianteeman - change - 13 Sep 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-09-13 08:52:19
Closed_By brianteeman
avatar brianteeman brianteeman - close - 13 Sep 2018

Add a Comment

Login with GitHub to post a comment