Resolved: Drawing .svg with javascript module “RDKIT-JS”


first of all I’m relatively new to javascript. So I’m sorry if my question is dumb. I would like to draw a molecule on my webiste by using this tool I also found an example here This example works in my case but when i try to invoke a function to draw a molecule as a .svg without using the example code, I fail. I get this error-message in my browser:
In the following code example you can see the first case where it works and the second case were it doesn’t. In both cases i use the same function.:
Later i would like to use the module to dynamically make those images. I use django as the framework. In this case i tried to present a minimal example without the django stuff.
Thanks in advance for your effort!


You are calling drawmol() before RDKit is ready.
To fix this, place it after RDKit is loaded:

If you have better answer, please add a comment about this, thank you!