No Code Attached Yet
avatar ced1870
ced1870
14 Oct 2025

Hi,
I'm using the Web Asset Manager to replace the old "addScript" method. The problem is that the WA does not render the file url correctly in call cases.

Tested with the function:
$wa = \Joomla\CMS\Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->registerAndUseScript($name, $url ...)

Problem 1 : it adds a wrong slash at the beginning

Standard test

Url used : /media/com_test/assets/script.js
Expected result (working with addScript) : <script src="/media/com_test/assets/script.js ...
Real result : <script src="//media/com_test/assets/script.js ...

there is an additional slash at the start of the file

Additional test :

If I use a variable in the url, then it works
Url used : /media/com_test/assets/script.js?rev=123
Real result : <script src="/media/com_test/assets/script.js?ver=123 ...

there is no additional slash

Problem 2 (the most important) : it adds the root at the beginning

This problem occours when you are working in a subfolder and using the multilanguage
Page url : http://localhost/joomlatest/index.php/fr/
Url used : /joomlatest/media/com_test/assets/script.js
Expected result (working with addScript) : <script src="/joomlatest/media/com_test/assets/script.js ...
Real result : <script src="/joomlatest/joomlatest/media/com_test/assets/script.js ...

the root is duplicated

why does the WA add some data to the url passed ? this must not be done. The url must be given by the variable passed to the function, and it must not be altered

avatar ced1870 ced1870 - open - 14 Oct 2025
avatar ced1870 ced1870 - change - 14 Oct 2025
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 14 Oct 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Oct 2025
avatar richard67
richard67 - comment - 14 Oct 2025

@ced1870 Always a good idea when report an issue: Let us know on which Joomla version you have observed it.

avatar richard67
richard67 - comment - 14 Oct 2025

@ced1870 Always a good idea when reporting an issue: Let us know on which Joomla version you have observed it.

avatar ced1870
ced1870 - comment - 14 Oct 2025

Build: 5.3.4 as stated in the report :)


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

avatar richard67
richard67 - comment - 14 Oct 2025

@ced1870 Unfortunately the build number can only be seen in the issue tracker but not on GitHub, so it always helps when mentioning it also in the text of the report.

avatar Fedik
Fedik - comment - 15 Oct 2025

It expecting relative path or URL.

Url used : /media/com_test/assets/script.js

This is not URL ;)

I think the code is expecting the path to be without leading slash.
It something with it

protected static function includeRelativeFiles($folder, $file, $relative, $detectBrowser, $detectDebug)

avatar ced1870
ced1870 - comment - 16 Oct 2025

I don't use the HTMLHelper, I use the $doc->addScript

the problem is that the way to work has changed.
something works with the $doc->addScript
the same DOES NOT work with the WebAssetManager

It's a fact and it's breaking things

Add a Comment

Login with GitHub to post a comment