I'm having a single page application, but with different tabs.
Only for one tab I want to show a google charts
. I don't want to include and load the charts js file jsapi
directly, but only if the specific tab is accessed.
Therefore I have to add the js as follows dynamically:
var script = document.createElement('script');
script.src = '//http://www.google.com/jsapi?ext.js';
document.body.appendChild(script);
Problem: how can I detect when the js has been completely loaded, so that I can continue as follows?
if (whenJspaiLoaded()) {
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart); //my custom function
}