window.addEventListener("load", () => main()); const main = () => { const cnv = document.getElementById("canvas"); const ctx = cnv.getContext("2d"); const size = 100; ctx.fillStyle = "blue"; ctx.fillRect( cnv.width / 2 - size / 2, cnv.height / 2 - size / 2, size, size ); };