What is the javascript filename naming convention?

ripper234 picture ripper234 · Sep 1, 2011 · Viewed 171.1k times · Source

Should files be named something-with-hyphens.js, camelCased.js, or something else?

I didn't find the answer to this question here.

Answer

Bryan Menard picture Bryan Menard · Sep 1, 2011

One possible naming convention is to use something similar to the naming scheme jQuery uses. It's not universally adopted but it is pretty common.

product-name.plugin-ver.sion.filetype.js

where the product-name + plugin pair can also represent a namespace and a module. The version and filetype are usually optional.

filetype can be something relative to how the content of the file is. Often seen are:

  • min for minified files
  • custom for custom built or modified files

Examples:

  • jquery-1.4.2.min.js
  • jquery.plugin-0.1.js
  • myapp.invoice.js