Images preloaded, but then re-loaded by browser anyway
hovi opened this issue · 2 comments
Issue Details
- Version used: createjs-2015.11.26.min.js
- OS & Browser version:
Version 64.0.3282.119 (Official Build) (64-bit), OS x 10.11.6
Hello, I tried using preload to simply preload my images, ex:
preload.loadFile("img/border.png");
preload.loadFile("img/illustrations/u0_0_rano.png");
preload.loadFile("img/illustrations/u0_3_test.png");
I am not really doing anything with result except for waiting for it all to complete.
I was expecting similar behaviour as if I used <link rel="preload" />
tag, but even though all images get loaded trough preloadjs, they are then loaded again when browser needs them.
I am pretty sure paths are all correct and completely identical. I checked all networking using chrome dev tools and it is just happening twice.
Am I missing something?
By default, PreloadJS uses XmlHttpRequests to load content (when possible), which provides some benefits, however you must use the preloaded content. If you use string-based image paths elsewhere in your application, the images are downloaded to the browser cache separately.
If you don't want to use the preloaded content directly, you can simply change the LoadQueue
instance to use tag-based loading (preferX=true
), and the images are preloaded using Image Tags into the browser cache.
var queue = new createjs.LoadQueue(false); // preferXHR is the 1st param
queue.loadFile(...);
To use preloaded content directly:
document.appendChild(queue.getResult("imageId"));
Hope that solves your issue!
Yes it did, thanks for quick reply!