Dashboard2 template node script loading?

I am trying to embed a vega-lite chart with the template node. But it seems there is a problem with loading multiple dependencies, which depend on each other.

Specifically:

    <script src="https://cdn.jsdelivr.net/npm/vega@5.28.0"></script>
    <script src="https://cdn.jsdelivr.net/npm/vega-lite@5.18.1"></script>
    <script src="https://cdn.jsdelivr.net/npm/vega-embed@6.25.0"></script>

The second file fails - presumably, because the first is not loaded yet, when it is loaded itself. Is there any way to control this better?

The "setInterval" trick works fine for one external dependency, but I hope I don't have to inject the scripts myself, after giving each time to load?

I was interested in this also .. Loading external scripts in a cleaner way than a timer.
Try this method ..

      mounted() {

            [
            'https://cdn.jsdelivr.net/npm/vega@5.28.0',
            'https://cdn.jsdelivr.net/npm/vega-lite@5.18.1',
            'https://cdn.jsdelivr.net/npm/vega-embed@6.25.0'
            ].forEach(function(src) {
            var script = document.createElement('script');
            script.src = src;
            script.async = false;
            document.head.appendChild(script);
            });


        },
1 Like

Did you try to add the defer attribute to all script tags ?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.