?
avatar Ruud68
Ruud68
26 May 2021

Steps to reproduce the issue

There are two JS files in the extension:

  • (full) abc/123/file1.js
  • (minified) abc/123/file1.min.js

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]);

Expected result

The file abc/123/file1.js should be loaded in the head of the page

Actual result

Joomla 3: correct! abc/123/file1.js is loaded
Joomla 4: INCORRECT > the minified file is loaded abc/123/file1.min.js

System information (as much as possible)

J3.9.27 and J4.0.0-beta8-dev

Additional comments

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.

avatar Ruud68 Ruud68 - open - 26 May 2021
avatar joomla-cms-bot joomla-cms-bot - labeled - 26 May 2021
avatar richard67
richard67 - comment - 26 May 2021

My personal opinion is that this issue should be closed as expected behaviour.

@dgrammatiko What do you think?

avatar dgrammatiko
dgrammatiko - comment - 26 May 2021

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!!!

avatar richard67 richard67 - change - 26 May 2021
Status New Expected Behaviour
Closed_Date 0000-00-00 00:00:00 2021-05-26 10:40:33
Closed_By richard67
avatar richard67 richard67 - close - 26 May 2021
avatar richard67
richard67 - comment - 26 May 2021

Closing as expected behaviour.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34228.

avatar Ruud68
Ruud68 - comment - 26 May 2021

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 :)

avatar richard67
richard67 - comment - 26 May 2021

You can re-open it yourself if you insist on it.

avatar rdeutz
rdeutz - comment - 26 May 2021

@Ruud68 can you explain why you want to load the full file when there is a minified file, can see the use case so far?

avatar Fedik
Fedik - comment - 26 May 2021

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.

avatar Ruud68
Ruud68 - comment - 26 May 2021

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...

avatar Ruud68
Ruud68 - comment - 26 May 2021

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?

avatar Fedik
Fedik - comment - 26 May 2021

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 :)

avatar richard67 richard67 - change - 26 May 2021
Status Expected Behaviour New
Closed_Date 2021-05-26 10:40:33
Closed_By richard67
avatar richard67 richard67 - reopen - 26 May 2021
avatar Fedik
Fedik - comment - 26 May 2021

okay, this should work for you

HTMLHelper::_('script', 'abc/123/file1.js', ['detectDebug' => false]);
avatar Ruud68
Ruud68 - comment - 26 May 2021

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...

avatar Ruud68
Ruud68 - comment - 26 May 2021

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?

avatar Fedik
Fedik - comment - 26 May 2021

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

avatar dgrammatiko
dgrammatiko - comment - 26 May 2021

okay, this should work for you

Actually, there's a bug and although this should work it doesn't. PR: #34232

avatar richard67 richard67 - change - 26 May 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-05-26 13:24:25
Closed_By richard67
avatar richard67 richard67 - close - 26 May 2021
avatar richard67
richard67 - comment - 26 May 2021

Closing as having a pull request. Please test #34232 . Thanks in advance, and thanks for reporting.

avatar Ruud68
Ruud68 - comment - 26 May 2021

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:

  • JDEBUG = true > the full version is loaded
  • JDEBUG = false > the minified version is loaded
  • JDEBUG = true AND detectDebug = false > the minified version is loaded
  • JDEBUG = false AND detectDebug = false > the minified version is loaded
  • JDEBUG = true AND detectDebug = true > the full version is loaded
  • JDEBUG = false AND detectDebug = true > the minified version is loaded
avatar Ruud68
Ruud68 - comment - 26 May 2021

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

avatar Ruud68
Ruud68 - comment - 27 May 2021

Closing as having a pull request. Please test #34244 . Thanks in advance, and thanks for reporting. :)

Add a Comment

Login with GitHub to post a comment