Search code examples
phpjavascriptweb-applicationsdirectory-structure

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,

  • 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)


Solution

  • 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.