Ah yes okay makes more sense now. Yes I have done that many times. Additionally you may want to add another library so make you http calls easier such as: Replacing Http-Connector with Jsoup usage
You could also use the nashorn “load()” function to load a specific Js file on the class path allowing you to have reusable functions and save you some duplication of code