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”:
/*! p5.js v1.1.9 July 22, 2020 */:
/*! p5.min.js v0.2.22 July 30, 2014 */:
Notice on the 2nd example its comment shows “v0.2.22”, although it shoulda been “v0.2.23”!
Unfortunately “v1.0.0” displays “v0.10.2”. Same problem some p5js versions are having:
/*! p5.js v0.10.2 February 29, 2020 */:
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:
And here’s the HTML which grabs “v1.0.0”:
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:
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”.