If I understand your question correctly, you want to add XSL variables in your JavaScript at the time the document loads. You would do that by inserting the variable directly into the JavaScript as it is being generated by the XSL. Say you are wanting to populate a choice box with the results of an XSL:for-each statement, you would insert the statment directly into the script and the browser, IE5+, or processor would evaluate those statements when the document loads. You do have to be careful trying to use XSL in your scripts where you try to assign values to objects that would require a "" around the value. You may have to use escape characters to get the referrence correct.
Hope this helps.