3 ms·
AFAIK, this could also be written as a transform in AssetGraph [https://github.com/assetgraph/assetgraph https://github.com/assetgraph/assetgraph], which does a
by msiebuhr 10y ago
AFAIK, this could also be written as a transform in AssetGraph [https://github.com/assetgraph/assetgraph https://github.com/assetgraph/assetgraph], which does all of the loading, parsing and traversing for you. At least the given description reads like the internals of the population/loader-system in AssetGraph.
As an added benefit, you'll get de-duplication, minification, inlining (with fallbacks) and, with a little work, image-spriting thrown in almost for free.
If you want to play around easily, take a look at https://github.com/assetgraph/assetgraph-builder https://github.com/assetgraph/assetgraph-builder