Reputation: 53
I made a script where provided image list will load all up, working like it should. Now this is my main question:
If I want to use this for let's say portfolio site where I want all project images, site background etc.. to preload and append image to place where they are in html, is there some solution already in preloadjs or do I have to let's say go trough whole page, get image sources and append to every single one of them? And is it possible to combine maybe to preload some assets you use in css or am I asking the impossible or rather hard to do? If any of this is possible, you don't have to send me code, just steps how you would do it (though code wouldn't hurt me).
Maybe I just don't understand for what exactly preloadjs is, I can't find really examples that will be useful to me so I ask here, maybe someone is willing to help me :)
Thanks.
Upvotes: 0
Views: 1303
Reputation: 11294
PreloadJS will load assets for you to do what you want with them.
Have a look at the samples that come with PreloadJS, which show you how content can be loaded and used: https://github.com/CreateJS/PreloadJS/
Simple example:
var queue = new createjs.LoadQueue();
queue.on("complete", handleComplete);
queue.loadManifest([
{src:"image.png", id:"image"},
{src:"script.js", id:"script"}
]);
function handleComplete(event) {
// Put the image into the body.
document.body.appendChild(queue.getResult("image"));
}
Hope that provides some help. PreloadJS assumes some knowledge of working with assets and the DOM in JavaScript.
Upvotes: 0