Guido Rossi
Guido Rossi

Reputation: 57

JS libraries and frameworks standard directories

In a web app, libraries are in directories like these:

/lib
/library
/libraries

/lib, /library, /libraries are de facto standards. Now,

Upvotes: 1

Views: 350

Answers (2)

Ethan Brown
Ethan Brown

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

OregonTrail
OregonTrail

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

Related Questions