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.

Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
Willy Lazuardi
  • 1,806
  • 4
  • 26
  • 41
  • 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 – Oliver Watkins Feb 08 '16 at 08: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. – vsync Jan 11 '17 at 20:09
  • Css and Js folders are nowdays styles and scripts – Yousha Aleayoub Jun 12 '20 at 22:05

1 Answers1

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.

Akhlesh
  • 2,389
  • 1
  • 16
  • 23