"dust" was designed for browser app,
specifically on nwjs. ( node.js(io.js) + browser component )
"dus" is "Data URL Scheme".
You can represent data in the URL.
data:[mime];base64,[binary]
[right click & copy link address ](#data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOAgMAAABiJsVCAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX/mWYAAAD//2bMzACyRM7sAA AAAXRSTlMAQObYZgAAAAFiS0dEAmYLfGQAAAAHdElNRQffCBECBCSsgoraAAAARUlEQVQI12NgAINABwYGxmUgYqajAwN71jUHBraslQwMbLuWAMVWTXVgYHwdDSJuAYlVsQwM7Fe/MDDITVzLwCAaGMoAAPkdEJQc4yGaAAAAJXRFWHRkYX RlOmNyZWF0ZQAyMDE1LTA4LTE3VDAyOjA0OjM2KzAwOjAwxuahVAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNS0wOC0xN1QwMjowNDozNiswMDowMLe7GegAAAAASUVORK5CYII=)
// example_1.js
var dust = require("dust");
var url = dust("./xxx.png").toDust(); // data:image/png;base64,(binary)
var img = new Image();
img.src = url;
document.body.appendChild(img);
Accumulate the binary data into memory, and then retrieve the data from there.
// example_2.js
var path = "./xxx.png";
var img_alpha = new Image();
img_alpha.src = dust(path).toDust(); // file read
document.body.appendChild(img_alpha);
var img_bravo = new Image();
img_bravo.src = dust(path).toDust(); // memory read
document.body.appendChild(img_bravo);
# directory
./app.js
./resource_load.js
./img/a.png
./img/b.png
./img/c.png
// resource_load.js
var path_a = "./img/a.png";
var path_b = "./img/b.png";
var path_c = "./img/c.png";
// app.js
if (! debug) dust().load(./dust.bin); // first binary load
var alpha = dust(path_a).toDust();
var charlie = dust(path_c).toDust();
*** ※ "debug variable" please you are prepared ***
# create "dust.bin" file
dust ./img dust.bin
# production env unuse raw files
rm -rf ./img