public static void writeHtmlImagePreloadJavaScript ( String url , Appendable out ) throws IOException { out . append ( "<script type='text/javascript'>\n" + " var img=new Image();\n" + " img.src=\"" ) ; // Escape for javascript StringBuilder javascript = new StringBuilder ( url . length ( ) ) ; encodeTextInJavaScript ( url , javascript ) ; // Encode for XML attribute encodeJavaScriptInXhtmlAttribute ( javascript , out ) ; out . append ( "\";\n" + "</script>" ) ; }
Prints a JavaScript script that will preload the image at the provided URL .