<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
const canvas = document.getElementById("canvas");
let ctx = canvas.getContext('2d');
let background = new Image();
background.src='background.png';
ctx.drawImage(background);
</script>
</body>
</html>
This is the code of the webpage. The path to the image is correct, I checked probably a 100 times. When I continue the code with the main loop it gives me a lot of errors.
I want to make a little 2d game with js, but for some reason the image doesn't load.