How to execute html <script> code in panel plugin?



I am in the middle of building a side panel that pulls in Gitter’s sidecar chat. I use the following code for my plugin:

        var plugin = new Panel("Gitter", main.consumes, {
            index: 300,
            caption: "Gitter",
            where: "right"
        plugin.on("draw", function(e){
            // Insert HTML from a file
            // ui.insertHtml(e.html, require("text!./gitter.html"), plugin);
            // Set some custom HTML
            e.html.innerHTML = "&lt;script&gt; ((window.gitter = {}).chat = {}).options = {room: 'gitterRoom'};&lt;/script&gt;&lt;script src=&quot;; async defer&gt;&lt;/script&gt;";

I’ve tried to escape the HTML string and also tried to import it using the require function but my script won’t execute when the panel launches.

Any advice would be great :slight_smile: