If you need to get the Path to the current Javascript file being executed, you can use this small function:
const location = (function () {
if (document.currentScript) {
let link = document.currentScript.src;
let lastIndex = link.lastIndexOf('/');
link = link.substring(0, lastIndex);
return link;
}
})();
In our code base, we use it to dynamically load Component dependencies.