I have a few large js files which functions and objects are living in the global scope and have function calls between them. Is there a relatively easy way to put them under local scope.
<script src="fileA.js"></script>
<script src="fileB.js"></script>
<script src="fileC.js"></script>
I’ve tried putting (function(){ at the beginning of the A file and })(); at the end of the last one but it doesn’t work.
10x for your kind help BR
No, there isn’t.
The closest you could come is to set them up to share variables through a namespace (a single, global variable with a name selected to make collisions unlikely) such as
window.YOUR_SCRIPT_NAME = {}.