I am on my phone, so I don’t have an environment to test, but this should work if you just want to remove the script altogether:
let canvasElement = document.getElementById(“canvas”);
canvasElement.parentNode.removeChild(canvasElement);
I explain how this script works here: https://www.kirupa.com/html5/creating_dom_elements_and_other_stuff.htm