| @@ -802,22 +802,16 @@ | ||
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | function visualizerLoadScripts() { |
| 805 | 805 | document.querySelectorAll("script[data-visualizer-script]").forEach(function(elem) { |
| 806 | - // Replace the placeholder with a real script tag using async=false: | |
| 807 | - // scripts download in parallel but execute in insertion order, which | |
| 808 | - // preserves the WordPress dependency order. Parallel jQuery.getScript | |
| 809 | - // calls could execute render-facade.js before the chart renderer had | |
| 810 | - // registered its render event listener, leaving charts blank. | |
| 811 | - var script = document.createElement("script"); | |
| 812 | - script.src = elem.getAttribute("data-visualizer-script"); | |
| 813 | - script.async = false; | |
| 814 | - script.onload = function() { | |
| 806 | + jQuery.getScript( elem.getAttribute("data-visualizer-script") ) | |
| 807 | + .done( function( script, textStatus ) { | |
| 808 | + elem.setAttribute("src", elem.getAttribute("data-visualizer-script")); | |
| 809 | + elem.removeAttribute("data-visualizer-script"); | |
| 815 | 810 | setTimeout( function() { |
| 816 | 811 | visualizerRefreshChart(); |
| 817 | 812 | } ); |
| 818 | - }; | |
| 819 | - elem.parentNode.replaceChild(script, elem); | |
| 813 | + } ); | |
| 820 | 814 | }); |
| 821 | 815 | } |
| 822 | 816 | |
| 823 | 817 | function visualizerRefreshChart() { |