How to know the Dojo version loaded in a web portal

How to know the Dojo version loaded in a web portal

dojo.logo

When you work with Dojo in a portal that is already in production mode, one of the first question you want to answer yourself is: what is the version of Dojo do I have available for using? Well, to answer that, just open you web browser console and run this small JavaScript code:

var v = dojo.version;
if(v.major > 1){
  // this is dojo 2.x
}else{
  // this id dojo 1.x
  switch(v.minor){
     case 1: console.log("1.1.x specific code"); break;
     case 2: console.log("1.2.x specific code"); break;
     case 7: console.log("1.7.x specific code"); break;
     case 9: console.log("this is 0.9, as major is less than 1, but not 1"); break;
  }
}

The dojo.version object contains some data like:

{
    "major": 1,
    "minor": 7,
    "patch": 2,
    "flag": "",
    "revision": 27913
}

As you can see, we have the major, minor and patch numbers, in this case I have the 1.7.2 version loaded in my portal.

I hope you find useful this article and remember be happy with your code!

See you next time!

  • Prev Post
  • Next Post