Search code examples
javascriptcssimageconfigurationfilestructure

js, img, css and ajaxcall folders?


when i download some new plugins eg. jquery plugins i put them in js folder. and the same for css and img.

so all my different applications share them. but where do i put my js/img and css for specific application/website? every website?

and where should i put my ajaxcall-files.php?

EDIT: some guides that could give me a clean and neat file structure?


Solution

  • I normally keep a file structure for javascripts as follows:

    - js
        - jQuery
        - flot
        - chilli
        - processing
        - closure
        - typical_library
              - js
              - css
              - img
    

    By keeping separate folders for each library/plugin (including the relevant css and images if it need be), the pain of maintenance during upgrades is less. There is one more advantage, predictable folder structures can help with autodiscovery of JavaScript base directories.

    For ajaxcall files (since I mostly use an MVC pattern), I keep them in the controller files. (I mostly use CodeIgniter). Some people would keep them in views, however if the ajaxcall.php involve any business logic is best to stick them in the controller files.

    In general minimize anything outside of folders.