Also I’m a great fan of the jQuery library and would most probably like to use it on the server side to perform modifications – saves a lot of time in working with the DOM. Luckily I also remembered a post of John Resig which explains exactly that issue (ok, Google helped me to find it ) – executing jQuery inside of Rhino. Using an application server like Jaxer is no option as the server environment is given. Issue 2 solved.
So, downloading Rhino, downloading env.js, downloading jquery.js, putting the sample together and, guess what, nothing worked. Uff. Even simple selectors like jQuery(‘div’).length always returned 0. After a little investigation I figured out that up to jQuery version 1.2.1 it worked like a charm, but the newer versions did not work anymore. But why? Hard to figure if there are not error messages shown.
What to do? Firing of a note to John Resig and – surprise – he wrote back within a few minutes, pointing me to a new version of env.js which also works with newer versions of jQuery.
So grab the new version of env.js and start using jQuery 1.2.6 on the server right now!