a krpano layer element is the same as a krpano plugin element
<layer url="mybutton.jpg" /> would be an image layer
<plugin url="myplugin.js" /> would be a js plugin
as described here, it does not matter if you write plugin or layer
https://krpano.com/docu/xml/#plugin
a js plugin example is here
https://krpano.com/docu/plugininterface/#top
(this is may not be something to start with, when using krpano)
of course you can insert layers from a js plugin:
krpano.actions.addlayer('mylayer');
var mylayer = krpano.layer.getItem('mylayer');
mylayer.url = 'mybutton.jpg';