How to detect if Raphaël is supported by the browser

Raphaël will set Raphael.type to ‘SVG’ when browsers supports it. Otherwise it will try to use VML and if it detects support, it sets type to ‘VML’. If not, type is set to null. So if you would like to use a fallback method of some kind, it would be beneficial to detect the condition of Raphaël not being supported by the browser. This is how you would do it:

if (Raphael.type) {
	//user Raphaël normally
} else {
	//fallback code

Another issue that I experienced when trying out the library in my previous post was that the text method failed in IE due to an ‘unknown runtime error’, so I had to fall back to PNG. This is easy to do by checking the value of the Raphael.type as well.

(This quick post is just for all the other poor souls out there like me that would like to quickly find a solution to this problem thru Google without actually reading the source code.)