I am trying to add text on an image using the element. First the image is drawn and on the image the text is drawn. So far so good.
But w
context.measureText(text).width is what you're looking for...
context.measureText(text).width