Supposing I have a script that might not always be present how do I make sure not to call if it doesn't exist?
HTML section
<script src="js/model.js"></script>
<script src="js/view.js"></script>
<script src="js/controller.js"></script>
<script src="js/script.js"></script>
(function(model, view, script){
"use strict";
document.addEventListener('loadata', function (e) {
script.loadData(e.detail);
});
Controller.js section
How do I stop Controller from making use of the script if it doesn't exist?
And how would I remove it from the HTML file?
EDIT: I also make one or 2 calls to functions in script from Controller
window.scriptFlag = truethen you can check for it anywhere in the code with something likeif( typeof window.scriptFlag != "undefined" )although I'm not sure why would you not be sure it is loaded, that seems to me a bad design logic. And of course it would cause trouble in that code, you would need first to check ifscriptexists and then use it.