I have an API that a number of my clients use, using my own specifications and instructions for manipulating it from their own sites. It means that, unfortunately for me, changing the HTML code on their side is not an option. This is the general idea how their code looks and I need to make it still work after I do the changes I want:
<script src="player.js"></script>
<script>
console.log(player.someProperty);
</script>
I want to do the following changes:
- rename player.js to player_2.0.js
- create a small script which will be named player.js so the HTML5 at the top would work like it did before. Then player.js would load player_2.0.js dynamically.
The problem is when the following part of the code gets to be exectuded
<script>
console.log(player.someProperty);
</script>
player_2.0.js still isn't done loading, resulting player.someProperty to be undefined.
So my question is if I can manipulate or postpone the 'onload' event for player.js script until it's done loading player_2.0.js, or do anything that could get me accomplish that.