The OnLoad event executes after all the nodes in the HTML document have been downloaded, including Js,css, and the picture's resources are fully downloaded.
If JS set the defer, JS parsing execution after the browser generated HTML document execution, not including the image of the resource download
If JS is not set defer, put a JS in the head load, will block the subsequent content loading.
As the following example
If Defer=true is removed, the following alert (' inline script ') will not execute until X1.jscript and X2.jscript are downloaded.
Alert (' win onload '); will not execute until the picture is loaded.
If JS and the image of the resource is the same Host,js loading will block the loading of the picture, only after the JS download is complete before downloading the picture.
In Firefox, there are 5 concurrent downloads.
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >. JScript is implemented by a Java servlet, simulating a download of a JavaScript file that requires a relatively long time
public class Jsprocessor extends HttpServlet {protected void doget (HttpServletRequest req, HttpServletResponse resp) thro WS Servletexception, IOException {try {System.out.println ("Begin processing"); String delaysec = Req.getparameter ("delaysec"); Thread.CurrentThread (). Sleep (Integer.parseint (delaysec) *1000); PrintWriter writer = Resp.getwriter (); Writer.write ("alert (' Done,delay +" + delaysec + "seconds ')"); SYSTEM.OUT.PRINTLN ("End Processing");} catch (Interruptedexception e) {//TODO auto-generated catch Blocke.printstacktrace ();}} protected void DoPost (HttpServletRequest req, HttpServletResponse resp) throws Servletexception, IOException {doget (req , resp);}}
. IMG is also implemented by a Java servlet, simulating a picture that takes a long time to downloadpublic class Imageprocessor extends HttpServlet {protected void doget (HttpServletRequest req, HttpServletResponse resp) t Hrows servletexception, IOException {try {resp.setcontenttype ("image/jpeg;charset=gb2312"); SYSTEM.OUT.PRINTLN ("Begin processing"); String delaysec = Req.getparameter ("delaysec"); Thread.CurrentThread (). Sleep (Integer.parseint (delaysec) *1000); String ImageFile = Getservletcontext (). Getrealpath ("/blog_logo.jpg"); System.out.println (imagefile); InputStream ImageIn = new FileInputStream (new File (ImageFile)); Jpegimagedecoder decoder = Jpegcodec.createjpegdecoder (ImageIn); BufferedImage image = Decoder.decodeasbufferedimage (); JPEGImageEncoder encoder = Jpegcodec.createjpegencoder (Resp.getoutputstream ()); Encoder.encode (image); Imagein.close (); SYSTEM.OUT.PRINTLN ("End Processing");} catch (Exception e) {//TODO auto-generated catch Blocke.printstacktrace ();}} protected void DoPost (HttpServletRequest req, HttpServletResponse resp) throws Servletexception, IOException {doget (req , RESP);}}
OnLoad event and JS defer settings