Hello I want to integrate Closure compiler by Google to compress my files with ADVANCED_OPTIMIZATIONS mode but I have 2 compressed files and I need to share variables between both.
I read this documentation https://developers.google.com/closure/compiler/docs/api-tutorial3
Issue
I got this error :
ReferenceError: getValue is not defined
so I tried to replace getValue by window['getValue'] but it does not working.
Basic code
First JS FILE :
var nb0 = 0;
var nb1 = 1;
var nb2 = 2;
var nb3 = 3;
function getValue( nb ) {
return nb;
}
window['nb0'] = nb0;
window['nb1'] = nb1;
window['nb2'] = nb2;
window['nb3'] = nb3;
window['getValue'] = getValue;
Second JS FILE :
document.addEventListener("DOMContentLoaded", function() {
var val = getValue;
document.querySelector( ".button" ).addEventListener( "click", upButton );
function upButton() {
val++;
document.querySelector( ".show" ).innerText = val;
}
} );
var val = window.getValue- Baruch