Drawing Molecules in Less Than 50 kB

down from a 22 MB Ketcher deployment

On the property prediction and similarity search pages of Cheméo, you draw a molecule and the server takes it from there. It predicts the properties, or it finds the closest compounds in the database. To let you draw that molecule in the first place, I was shipping Ketcher.

Ketcher is a fine molecule editor. It is also 22 MB. Twenty-two megabytes of JavaScript, so that someone can draw a hexagon with a couple of substituents and press a button.

I have been here before. Ten years ago I built my own small drawing tool for the same job. Back then Ketcher was around 3 MB, and even that already felt heavy. My own tool stayed under a megabyte and did the work, until a handful of small bugs, here and there, wore me down and I switched back to Ketcher. Ketcher fixed the bugs. It also kept growing while I was not looking, from 3 MB to 22 MB.

So I took four days of my vacation and built its replacement. The new drawing component is under 50 kB. Kilobytes, not megabytes, more than four hundred times smaller than the thing it replaced.

It does only what Cheméo needs, no less and no more. You place atoms and bonds, you pick an element, you drop in a common ring from the menu, you erase, you undo. That is the whole job. No reaction arrows, no sprawling template library, no zoo of file formats, none of the hundred things a general editor has to carry because someone, somewhere, needs each one. Here nobody does, so none of it is in the bundle.

The structures come out in the style of RDKit. Any chemist who has plotted a molecule in Python will recognise the look at a glance: the bond angles, the way the atom labels sit, the colours on the heteroatoms. That familiarity is the point. A structure that looks the way you expect is a structure you trust while you are still drawing it. And yes, the first molecule I drew to test it was TNT, the same mandatory trinitrotoluene I used to break in the tool ten years ago.

Here is that molecule in both tools, ten years apart.

2,4,6-trinitrotoluene drawn with my 2015 tool

The 2015 tool, later dropped for Ketcher.

2,4,6-trinitrotoluene drawn with the new component

The new component: the same molecule, cleaner lines, a fraction of the weight.

The easy path is always to add one more feature and one more dependency, until the download quietly climbs to 22 MB. This week I took the other one. The new component loads before you notice it loaded, and there is so little of it that almost nothing is left to break in ten years.

Draw something on /predict or /similar and see for yourself.

Fluid Phase Equilibria, Chemical Properties & Databases
Back to Top