Where to put a js.map file?

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 345
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Where to put a js.map file?

Post by MarkRS » Sat Mar 23, 2024 3:57 pm

Got one of these, but where should it go in the J! structure to get recognised by the browser?

It's for an externally minified js file so the J! processes don't apply/
It's a community, the more we all contribute, the better it will be.

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 345
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Where to put a js.map file?

Post by MarkRS » Wed Mar 27, 2024 11:29 am

It seems my question makes the wrong assumption, that there is a correct place to put that map.

In fact, it seems that the map can be anywhere, it just needs to be specified to Joomla.

One way to do this is to include it in the json assets file. The way I've done it is

Code: Select all

"name":"<my component>.<entry name>",
"type": "script",
"importmap": true,
"uri": "/media/<my component>/js/<map file name>",
"dependencies": [ "core" ],
"attributes": {
   "defer": true
}
The ("a"?) key point is the "importmap" entry.
I don't s'pose the "dependencies" entry is required, nor perhaps the defer attribute.
It seems to require the full path in the uri, this appears to be a full path.
I also s'pose it doesn't have to be in the js directory.

I imagine this can also be done with a "registerAndUseScript" method call on the Web Asset Manager in the default.php (or whichever your file is), ie without including it in the assets file.

You're welcome.
It's a community, the more we all contribute, the better it will be.


Post Reply

Return to “Joomla! 5.x Coding”