

Ask HN: What do you use for Javascript, CSS, and image dependency management? - neilk

Past a certain point of complexity, it becomes desirable to have a framework to manage all the various JS, CSS and image files that one uses into "modules" of functionality, some of which might even be loaded on-demand from the client.<p>If you have this problem, how do you solve it? Do you use a framework like YUI? Something else?<p>What in your opinion is a must-have for such a framework?
======
JangoSteve
I'm not sure I understand the question. Some javascript files depend on
functions provided in others, but what are CSS and image dependencies? Are you
referring to stylesheets that specify image backgrounds?

~~~
neilk
CSS files that need images are an example of this, yes, but the browser
handles that anyway (you might want to preload it, for efficiency, though).

For example, imagine a user profile page on a social network.

The page might come preloaded with a Javascript widgets that you use all over
your site, like a common interface element to hide and expand content. These
widgets might demand some base Javascript libraries, as well as their own CSS
classes and images.

Then, if the user wants to edit their hometown, we might want to load a map
widget. Since this is a rare thing, we didn't include it in the page, but we
decided to load it on demand. Once again we might load a lot of base JS, CSS
or images.

Now, obviously this is all possible by inserting each dependency manually. But
when your site gets really big and dependencies get very complicated, one
wants to be able to say to a framework "hey, framework, go make sure this page
has everything it needs for hide/expand widgets". Or, "hey framework, the user
just clicked 'edit hometown', so now we need everything required for map
widgets".

~~~
JangoSteve
I think I see what you're getting at. I don't know, I usually just pack
everything into a single minimized javascript file and include that on every
page. It may take longer for the user's browser to download the first time,
but then it's cached on their machine for every page when they're browsing and
when they return several days later.

