How to add javascript to JBrowse after everything has loaded

79 Views Asked by At

I'm trying to add a script tag to the body of index.html in JBrowse 11.5. I want it to be executed after everything has loaded. All the CSS, asynchronously loaded tracks and so on. I've tried domReady! and dom/ready but they are triggered too early. Does anyone know how to add a script after all has loaded?

1

There are 1 best solutions below

0
On

It might depend on what you mean by "everything being loaded", but you could try a couple different methods.

For example, in index.html you might write something like this

JBrowse.afterMilestone('initView', function() {
    // add your code to inject script here
})

You can just add arbitrary javascript there, include new AMD modules, or use some other code injection type method e.g. inject a script tag with remote src and wait for it to execute

Alternatively, check out the plugin architecture for JBrowse, it is also a good way to include new code modules