Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I put the version number of my JavaScript library in the file name?

Tags:

javascript

I am about to release a javascript library.

I would like to save the file as [library-name].1.0.0

Then as the library will evolve you will be able to download new versions, e.g.

  • [library-name].1.0.1.js
  • [library-name].1.0.2.js
  • [library-name].1.0.3.js
  • [library-name].1.1.0.js
  • [library-name].1.2.0.js
  • [library-name].2.0.0.js

My question is: is there any reason not to save the version in the name of the file?

I am using other 3rd party libraries and the ones for which I don't store the version I always have to figure out if I have to upgrade or not.

For instance, I use codemirror.js, and I always wonder if I am using the latest version.

like image 804
Zo72 Avatar asked Oct 04 '22 12:10

Zo72


2 Answers

If you are giving it for download, then its a good idea to have version number as part of file name. Also its a good idea to add version number along with the license info at the beginning of the file like jQuery does

Checkout - http://code.jquery.com/jquery-1.9.1.min.js

Only case where you shouldn't add version number is when you are referencing a script file throughout your website - because you don't want to change all references whenever you update the script.

like image 76
Sunil Urs Avatar answered Oct 10 '22 11:10

Sunil Urs


I've never released any libraries myself, but putting the version number in the file name sounds like a fine idea to me.

On upgrading, I think not putting the version number in the file name is used for libraries where the author doesn't expect to introduce breaking changes in future versions, only bug fixes and additions that don't affect code already written against the library. This means that people who use the library but don't host it themselves (i.e. who point to the library on a public CDN) automatically point to the latest version, and thus get bug fixes without having to do anything.

But, as you say, for people who download the library and host it themselves, it does mean they have to open the library file to check the version number.

If you want to match what some other library publishers do, you might want to have a look at Semantic Versioning - it codifies the x.x.x version numbering system.

And if you're going to release your library through Github (which I believe is what the cool kids do these days), you might want to use Jonathan "Wolf" Rentzsch's system for doing semantic versioning there.

like image 44
Paul D. Waite Avatar answered Oct 10 '22 11:10

Paul D. Waite