I am building a website with CodeIgniter, I have various resources that I load with the base_url helper function like this
One way is to use a script tag to import the variables you want to your views:
Here, I wrapped the base_url with json_encode so that it'll automatically escape any characters to valid Javascript. I put base_url to the global Window so you can use it anywhere just by calling base_url, but make sure to put the script tag above any Javascript that calls it. With your given example:
...
$('#style_color').attr("href", base_url + "assets/css/themes/" + color_ + ".css");