Update JavaScriptUtils.java

Had time to test the changes and adjusted them accordingly. For me this works great and could help our project considerably.