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.
plugin pair can also represent a namespace and a module. The
filetype are usually optional.
filetype can be something relative to how the content of the file is. Often seen are:
minfor minified files
customfor custom built or modified files
As to file naming, it is purely a matter of preference and taste. I prefer naming files with hyphens because then I don't have to reach for the shift key, as I do when dealing with camelCase file names; and because I don't have to worry about differences between Windows and Linux file names (Windows file names are case-insensitive, at least through XP).
So the answer, like so many, is "it depends" or "it's up to you."
The one rule you should follow is to be consistent in the convention you choose.
- Use all lowercase filenames. There are some operating systems that are not case sensitive for filenames and using all lowercase prevents inadvertently using two files that differ only in case that might not work on some operating systems.
- Don't use spaces in the filename. While this technically can be made to work there are lots of reasons why spaces in filenames can lead to problems.
- A hyphen is OK for a word separator. If you want to use some sort of separator for multiple words instead of a space or camelcase as in
various-scripts.js, a hyphen is a safe and useful and commonly used separator.
- Think about using version numbers in your filenames. When you want to upgrade your scripts, plan for the effects of browser or CDN caching. The simplest way to use long term caching (for speed and efficiency), but immediate and safe upgrades when you upgrade a JS file is to include a version number in the deployed filename or path (like jQuery does with jquery-1.6.2.js) and then you bump/change that version number whenever you upgrade/change the file. This will guarantee that no page that requests the newer version is ever served the older version from a cache.
There are some various options:
are all valid naming conventions, however I prefer the jQuery suggested naming convention (for jQuery plugins, although it works for any JS)
The beauty to this naming convention is that it explicitly describes the global namespace pollution being added.
Because I left out versioning: it should come after the full name, preferably separated by a hyphen, with periods between major and minor versions: