I haven't used PhoneGap much, but I looked into this and it seems that (at least on the latest phonegap, I have 2.9), deviceready is a sticky event - even if you don't register a callback until after it's happened, it'll fire the callback. So I assume you've currently got something like:
document.addEventListener('deviceready', run, false);
in a plain javascript section. If so, you should be able to just move it into the bottom of your text/sjs block, and it should work. If SJS is executed before the device is ready then you've registered the handler before the event happens, just as JS would. If SJS loads after the device is ready, phonegap still seems to trigger the event.
If that doesn't work (perhaps this is new to 2.9), note that inline SJS and JS in a html file share the same global scope. So you can use a shared variable for this purpose:
<script type="text/javascript">
var deviceready = false;
document.addEventListener('deviceready', function() {
deviceready = true;
}, false);
</script>
<script type="text/sjs">
function run() {
console.log("let's go!");
}
if (deviceready) {
run();
} else {
document.addEventListener('deviceready', run, false);
}
</script>
.. but hopefully that's not necessary.
Hope that helps,
- Tim.