check for existence of document in curl.js when finding script element since it happens before ssjs.js module is executed