I have a little generated JavaScript from a JSP page that looks like this:
var elem = document.getElementById("image");
elem.src = "Image?step="+step;
The code snippet above is called when the user clicks on a button, and step is a variable that is increased with every run of the function. Image is a Servlet that generates a PNG-encoded Image.
This works, but it is very slow because the Server must generate the Image when the Client wants it. I know I could pre-load the Image, but I thought of a better solution. Since I know how many steps are allowed, I thought of generating the Images when the page is requested, and embed them into the JavaScript, maybe Base64-encoded so that the Image can be viewed on all OS.
Is it possible to do this? If yes, how could I implement it? I don't want to use external JavaScript frameworks like jQuery, and I don't care about browsers that are not really common, it'll be enough if it works with Mozilla browsers and Google Chrome.
var imagestring = <base64-encoded-image>and then decode that image if the browser should show itimage/pngisn't base64-encoded and I want to have it work on multiple OS