 <p>I imagine the reason it's not working is because the context in which it'll look for your function will be the top one, i.e. the window.</p> <p>What you'll need to do is rename the function <code>window.subscribe_callback = (data)-&gt;</code> etc instead.</p>