There are two JS files in the extension:
load the (full) js file via HTMLHelper (note: relative = false because the file is NOT located in the media folder)
HTMLHelper::_('script', 'abc/123/file1.js', ['relative' => false]);
The file abc/123/file1.js should be loaded in the head of the page
Joomla 3: correct! abc/123/file1.js is loaded
Joomla 4: INCORRECT > the minified file is loaded abc/123/file1.min.js
J3.9.27 and J4.0.0-beta8-dev
J4 forces the loading of minified files when they are found based on the full filename. This behavior can only be toggled via the global JDEBUG setting, this way it is for extension developers NOT possible to load the full version based on an extension setting.
Loading the file via J4 webassetmanager has the same behavior as the uses HTMLHelper::_('script', ...) to to get the file to load.
It is expected behaviour. If a minified file exists (and not in debug mode) that one will be served.
Also please DON'T serve static assets outside of the media folder!!!
| Status | New | ⇒ | Expected Behaviour |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-05-26 10:40:33 |
| Closed_By | ⇒ | richard67 |
Closing as expected behaviour.
It is expected behaviour. If a minified file exists (and not in debug mode) that one will be served.
Also please DON'T serve static assets outside of the media folder!!!
file and locations where only there for showing the issue :0 not a path I would use myself :)
Closing as expected behaviour.
although 'expected', still different as to what the same function does in J3.
In my experience there is a difference in expected behavior and changed behavior :)
Not saying that the issue should be resolved, but at least this should be described as changed behavior when going to J4.
If it wasn't an issue I would have not ran into it when migrating my extensions, not being able to pick which file (full / minified) other then with the all or nothing approach (JDEBUG) is breaking functionality for me :S
so please reopen :)
You can re-open it yourself if you insist on it.
If you have minified files, then use:
HTMLHelper::_('script', 'abc/123/file1.min.js', ['relative' => ... can be false or true]);
Then it will be good on both.
Hi, thanks for the follow up.
If you have minified files, then use:
HTMLHelper::_('script', 'abc/123/file1.min.js', ['relative' => ... can be false or true]);Then it will be good on both.
That is not what I want, I want to have control over full or minified, not minified only.
@rdeutz
using the full version for debugging purposes over e.g. an extended period of time. In my extensions I have an advanced setting: debug yes/no that toggles this (amongst others).
Setting the global debug to yes (JDEBUG) is in many cases 'overkill' as that impacts everything (and changes more them my extension alone): my customers 'panic' when the interface changes in the back-end).
So the use case is for debugging purposes where global JDEBUG is not allowed / desired.
I understand that I used a 'loop-hole' in J3 to accomplish this and have been looking at a way around it for J4 but using the API functions don't allow this, adding an additional option to the $options (e.g. 'debug' => true) would be a possibility but would then require changes to / an additional param passed to protected static function includeRelativeFiles($folder, $file, $relative, $detectBrowser, $detectDebug), something like this:
protected static function includeRelativeFiles($folder, $file, $relative, $detectBrowser, $detectDebug, $debug = false)
{
// Set debug flag
$debugMode = false;
// Detect debug mode
if ($detectDebug && (JDEBUG || $debug))
{
$debugMode = true;
}
....
it would also require changes to the webassesmanager way as that doesn't pass the options at all for fetching the files (it creates its own fixed options (relative and pathonly), which IMO is also not correct...
You can re-open it yourself if you insist on it.
I can only comment? there used to be a reopen button, but now I only have a comment button?
That is not what I want, I want to have control over full or minified, not minified only.
HTMLHelper::_('script', 'abc/123/file1.min.js', ['detectDebug' => true]);
hm, or maybe not :)
| Status | Expected Behaviour | ⇒ | New |
| Closed_Date | 2021-05-26 10:40:33 | ⇒ | |
| Closed_By | richard67 | ⇒ |
okay, this should work for you
HTMLHelper::_('script', 'abc/123/file1.js', ['detectDebug' => false]);
okay, this should work for you
HTMLHelper::_('script', 'abc/123/file1.js', ['detectDebug' => false]);
I thought I could use that option ,but that doesn't work...
if ($detectDebug && JDEBUG)
$detectDebug only works in conjunction with JDEBUG = true :)
furthermore, webassetmanager (if we want to use that over htmlhelper::_('script',...)) strips all options and falls back to these two:
// Get the file path
$file = HTMLHelper::_(
$type,
$path,
[
'pathOnly' => true,
'relative' => !$this->isPathAbsolute($path),
]
);
So that is also a 'dead-end' as it drops options detectBrowser and detectDebug...
furthermore, webassetmanager (if we want to use that over htmlhelper::_('script',...)) strips all options and falls back to these two:
// Get the file path
$file = HTMLHelper::_(
$type,
$path,
[
'pathOnly' => true,
'relative' => !$this->isPathAbsolute($path),
]
);
So that is also a 'dead-end' as it drops options detectBrowser and detectDebug...
@dgrammatiko is this intended behavior for the resolvePath function in WebAssetItem?
for WebAssetItem it is correct,
well, just use JDEBUG :)
btw, you can disable the debug plugin safely, to reduce overhead.
I do not have other ideas for now
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-05-26 13:24:25 |
| Closed_By | ⇒ | richard67 |
PR doesn't work (reported that in the PR).
The issue here is that there currently is no way to set a debug boolean for an extension, only JDEBUG is used. the detectDebug overrules JDEBUG nothing more, nothing less:
I do not have other ideas for now
only workaround to get this working is if you want the full version you prepend it with https://yourdomain/pathtoyourfile.js
This is handled correctly as it is bypassing all the selection / minification logic.
IMO this should either be documented as changed behavior J3 vs J4 or 'fixed' in J4 where there are multiple approaches to do so. it then comes down to requirements
My personal opinion is that this issue should be closed as expected behaviour.
@dgrammatiko What do you think?