javascript - How can I preload images in a Worker? -


I try to preload an image in a worker:

  Var img = new Image);  

This will get an error for: Unwanted references: Image is not defined.

Are there other ways to preload the images in a worker? Can XMLHttpRequest do this?

If so, when I use to preload XMLHttpRequest images to work, then will my main UI thread cache that image?

Should I use the image or XMLHttpRequest in my main ui thread?

Workers with the Web, you do not have access to the DOM in the same way, as you are referring to the page Want to run javascript in Web laborers go in their own context, but this does not mean that you can not pre-load images, you have to do it differently, for example:

  var x = New XMLHttpRequest (); X.responseType = 'blob'; X.onload = function () {// something} x.open ('GET', url, true); X.send ();  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -