I am building a website with CodeIgniter, I have various resources that I load with the base_url helper function like this
To get exactly the same thing as base_url of codeigniter, you can do:
base_url
codeigniter
var base_url = window.location.origin + '/' + window.location.pathname.split ('/') [1] + '/';
this will be more useful if you work on pure Javascript file.