// window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/'
document.currentScript.src.toString().substring(0, document.currentScript.src.toString().lastIndexOf('/'))+ '/'
if path of js file is https://cdn.jsdelivr.net/npm/bbb/mmm.js
it returns https://cdn.jsdelivr.net/npm/bbb/
function getScriptFileName() {
return (new Error).fileName;
}