3 ms·
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
by JangoSteve 16y ago
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 16y agoCSS 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 16y agoI 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.