# Detect p5 1.1.9 vs 1.0.0?

**URL:** <https://discourse.processing.org/t/detect-p5-1-1-9-vs-1-0-0/22920>\
**Category:** Coding Questions\
**Created:** [July 30, 2020, 5:29am UTC](https://discourse.processing.org/t/detect-p5-1-1-9-vs-1-0-0/22920 "2020-07-30T05:29:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 31, 2020, 4:54am UTC](https://discourse.processing.org/t/detect-p5-1-1-9-vs-1-0-0/22920/2 "2020-07-31T04:54:13Z")

</div>

> [@grege2](#):
>
> … to include a “version number” but it has not gained approval).

I’m also puzzled why devs from both Processing Java & p5js flavors so adamantly refuse to add some way for a sketch to inspect which version it is running on. 🤪

Indeed the p5 constructor doesn’t contain any info about its version.  
The only place I’ve found it was inside the “p5.js” file itself on its 1st line as a comment block.

Take a look at these 2 examples below.  
1st is from the current “v1.1.9” and 2nd is from a very old “v.0.2.3”:

1. /\*! p5.js v1.1.9 July 22, 2020 \*/:  
[cdn.JsDelivr.net/npm/p5@1.1.9](http://cdn.JsDelivr.net/npm/p5@1.1.9)
2. /\*! p5.min.js v0.2.22 July 30, 2014 \*/:  
[Unpkg.com/p5@0.2.23/lib/p5.min.js](http://Unpkg.com/p5@0.2.23/lib/p5.min.js)

Notice on the 2nd example its comment shows “v0.2.22”, although it shoulda been “v0.2.23”! 😒

> [@grege2](#):
>
> … how to detect whether you’re running on 1.0.0 or 1.1.9?

Unfortunately “v1.0.0” displays “v0.10.2”. Same problem some p5js versions are having: 🤕  
/\*! p5.js v0.10.2 February 29, 2020 \*/:  
[cdn.JsDelivr.net/npm/p5@1.0.0](http://cdn.JsDelivr.net/npm/p5@1.0.0)

BtW, I’ve finished creating a new p5 method called **getVersion()** which uses **loadStrings()** to download the p5js library as text and then grab its comment block version via a regex expression I’ve made up:  
`/p5(?:\.min)?\.js v(\d+)\.(\d+)\.(\d+)/`

> <https://gist.github.com/GoToLoop/6125a5806872f7d4d93d11870b607851>
>
> There are more than three files. show original

And here’s the HTML which grabs “v1.0.0”:  
[Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v1.0.0.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v1.0.0.html)

However, you’re gonna need to look for other unique features which “v1.0.0” has & “v0.10.2” doesn’t, so you can tell them apart. 🕵️‍♂️

For more tests here’s the complete list of 10 HTML links, each pointing to a different p5js lib version: 📜

1. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851)
2. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/latest.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/latest.html)
3. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v1.0.0.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v1.0.0.html)
4. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.10.2.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.10.2.html)
5. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.6.1.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.6.1.html)
6. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.5.16.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.5.16.html)
7. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.4.24.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.4.24.html)
8. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.3.16.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.3.16.html)
9. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.2.23.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.2.23.html)
10. [Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.2.22.html](http://Bl.ocks.org/GoToLoop/raw/6125a5806872f7d4d93d11870b607851/v0.2.22.html)

P.S.: The 10th link (v0.2.22) fails to grab its version b/c it doesn’t have a comment block! ⛔  
Apparently that versioning model starts at “v0.2.23”. 🆗

---

_[View the full topic](https://discourse.processing.org/t/detect-p5-1-1-9-vs-1-0-0/22920)._
