Search code examples
createjs

createjs/preloadjs: What is "tag loading"?


In the preloadjs docs, I see this referred to but I can't tell what it means and there's no definition.

Creating a Queue
To use LoadQueue, create a LoadQueue instance. If you want to force tag loading where possible, set the preferXHR argument to false.

I know what XHR is, but I don't know what "tag loading" means in this context, or what it means in terms of how the library will operate.


Solution

  • Tag loading uses HTML tags to load content.

    For example, this is a tag loaded image:

    var img = document.createElement("img");
    img.src = "path/to/image.jpg";
    

    Most content can be loaded using tags. The main exceptions are anything text-based and webaudio.

    Tag-loaded images are handled by the browser, and download to the browser cache. They don't provide things like progress events, which is why PreloadJS prefers to load with XHR. That said, tag-loading works better with the browser cache, so if you plan on using string-paths with your content (and not passing references to preloaded content), stick with tag-loaded images :)