I have written a small js script that will provide a booking var for my other scripts.
Small excerpt of script:
var booking={
venue: null,
baseUrl: "http://fancy.url.com",
align: "right",
top: "200px",
image: null,
id: 0,
height: null,
width: "162px",
action: "Boka",
text: "Hello!",
openStartpage: false,
buttonColor: "green",
// Variables
imageUrl: "/assets/images/button/",
sayHelloToConsole: function (){
console.log(hello);
}
};
booking.init();
I load the script async with:
<script type="text/javascript">
var _booking = _booking || {};
_booking["venue"] = "venue";
_booking["id"] = 3460483;
_booking["baseUrl"] = "http://localhost:9000";
_booking["buttonColor"] = "blue";
(function() {
function asyncLoad(){
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'http://localhost:9000/assets/javascripts/booking.min.js?v=1.0';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent)
window.attachEvent('onload', asyncLoad);
else
window.addEventListener('load', asyncLoad, false);
})();
</script>
I let googleClosureComiler minify the script so that I can access the file in my play app. I have not provided any compiler options in my build.sbt file.
I then try to use the minified file the compiler has put in my public folder but the compiler has done something very strange with the variables in the minified file. E.g my variable is named booking$$module$booking instead of booking. So when I want to access booking I get an error that booking is not defined. booking$$module$booking is defined and working.
Why did the compiler rename booking to booking$$module$booking? How do I prevent this from happening?