@yletzter this trick only works in instances like
function () X = true
and does the same thing as
function () {
return X = true
}
It is unique to Nashorn.
In this case you need to write
function () {
if (module.state) print("xd")
}
or
function () module.state && print("xd")
But if you check for it in onLoad then all scripts should already be loaded and you don't have to timeout.