Abhijit
Abhijit

Reputation: 1173

Javascript library version support

I have developed a small widget library of Chart controls and wondering if there is a best practice approach to version or meta tag my JS files so that when I bring out a new release, the version checking code would take care of compatibility across new and older versions. To begin with I need to record the current version somewhere. Any suggestions? I'ven't yet looked at how JQ identifies itself...would it be only the filename?

Upvotes: 4

Views: 1152

Answers (2)

Abhijit
Abhijit

Reputation: 1173

for version maintainence, this should do.

myLibrary.version = { 
 major : 1, 
 minor : 4, 
 datetime : "20110225223456", 
 toString : function () {
    return this.major+ "." + this.minor;
    }  
}

and for loader mechanism, I found this is nice place to begin with ..http://ajaxian.com/archives/modulesjs-a-new-stand-alone-javascript-module-loader or in particular http://requirejs.org/ useful.

And something I just came across.. http://labjs.com/

Upvotes: 0

Jeff Beck
Jeff Beck

Reputation: 3938

If you are using a loader you will need to maintain the loader itself I would look at the way google deals with loading JS. It allows the user to select major minor or point release specificity to a library.

http://code.google.com/apis/loader/

Upvotes: 1

Related Questions