Reputation: 57
In a web app, libraries are in directories like these:
/lib
/library
/libraries
/lib, /library, /libraries are de facto standards. Now,
where should we locate JS libraries? (e.g. jQuery)
where should we locate JS frameworks? (e.g. Backbone.js, Knockout.js, Ember.js, Angular.js)
Upvotes: 1
Views: 350
Reputation: 27282
For what it's worth, I put third-party libraries and frameworks (I don't really see a need to distinguish between them) in a directory called /vendor
. I prefer putting it there because it clearly separates libraries we have written (which naturally go in /lib
) from unmodified vendor libraries (a.k.a. dependencies).
One thing to consider is that a lot of libraries (Bootstrap, for example) come with more than just JavaScript: there's CSS and images too. Nothing annoys me more than a third-party library that wants to put its CSS in my root /css
, images in my root /img
, etc. I want all those dependencies kept together. So my directory structure looks something like this:
/
lib/
mylib.js
css/
mycss.css
img/
myimg.png
vendor/
jquery-1.10.0.min.js
bootstrap/
img/
bootstrapglphs.png
css/
bootstrapcss.css
Upvotes: 1
Reputation: 9039
It's really up to you.
In a Django webapp, for example, it makes sense to keep these files in the STATIC_FILES dir specified by your settings file, because they are downloaded by clients and should be served statically.
Then you may want to have a versioning system for these files based on filename or directory name, so that you can instruct your HTTP server to set proper expiry headers.
There is a fundamental difference here from /lib in a C project, because these are files that are served to clients and should be able to be cache-busted at any time.
Upvotes: 0