Why use 'lib' vs 'src' directory names in JavaScript? Which is 'standard'?
Solution 1
Interesting question, but it seems to me that some developers just take it by their own worldview.
It also depends on the project:
Some projects are built with smaller components, which are just little pieces of the main functionality: lib
.
lib/independent-pieces.js
Other projects are monolithic, the components depend on each other: src
.
src/this-is-all-for-this-project-and-depend-on-each-other.js
For third-party libraries, it's common to use vendor
.
vendor/bootstrap/
vendor/d3/
Solution 2
/node_modules
- for 3rd party libraries./lib
or/vendor
- suggested putting your libraries which is not required for compilation./src
- for your code source
simbolo
Everything From CRM, CMS, eCommerce and business applications from desktop, web and mobile. Strictly web applications only. Special interest in security and privacy.
Updated on June 02, 2022Comments
-
simbolo over 1 year
There are many popular JavaScript libraries and applications on GitHub and some put their raw source code in a
/src
directory, and others in a/lib
directory.I'm leaning towards the developers having done this depending on which languages they were taught growing up. So I see a lot of Java developers use
/lib
(who also normally end up putting their packaged JS into a/bin
directory). Meanwhile I often observe that those who use/src
output their packaged JS into a/dist
folder instead.What is considered the standard pattern for JavaScript,
src
orlib
. Maybe there isn't a right or wrong answer at all.