111

How do you organize your js & css folder in your web application?

My current project structure is like this one:

root/
├── assets/
│   ├── js/
│   │   └──lib/
│   ├── css/
│   └── img/
└── index.html

But it's more complicated when I use many javascript library & css plugin. Javascript plugin comes with its own .js file and sometimes with its own .css file.

For example, when I use JQuery with JQueryUI plugin, I put the jquery.js and jquery-ui.js inside js/lib directory. But JQueryUI comes with its own css file. Where should I put the css from javascript plugin for best practice? Should I put them inside lib folder, to distinguish my css and javascript css plugin? Or somewhere else?

I know it's a personal preferences, but I just wanna know how you guys organize your project folder.

3
  • keep CSS in the same folder as JS if the CSS is related to the component. Ie. you have table.js, then the table.css is next to it in the folder. That way you don't get lost trying to find CSS Commented Feb 8, 2016 at 8:28
  • It depends on the scale of the project. generally speaking, IMHO, all projects should use task runners (NPM/GULP) so you should have a build folder and src folder probably. Commented Jan 11, 2017 at 20:09
  • Css and Js folders are nowdays styles and scripts Commented Jun 12, 2020 at 22:05

1 Answer 1

18
 root/
   assets/
      lib/-------------------------libraries--------------------
          bootstrap/--------------Libraries can have js/css/images------------
              css/
              js/
              images/  
          jquery/
              js/
          font-awesome/
              css/
              images/
     common/--------------------common section will have application level resources             
          css/
          js/
          img/

 index.html

This is how I organized my application's static resources.

Sign up to request clarification or add additional context in comments.

3 Comments

but where do you put the JS source files and minified files?
you can keep in same directory.
Think there should be separate directories for source and distribution

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.