is an "unrendered" video element less heavy

Viewed 20

I am editing a code where a newly created video element is given a stream and then passed to a canvas for rendering.
I tried shortening the code I got, to make it more readable:

const video = document.createElement('video');
video.srcObject = await navigator.mediaDevices.getUserMedia({
    audio: false,
    video: {width: 284, height: 430, facingMode: "user"}
});
const canvas = document.getElementById("self-canvas");
const ctx = canvas.getContext('2d');
function draw_2DCanvas(){
    ctx.clearRect(0,0, canvas.width, canvas.height);
    ctx.drawImage(video, 0,0, canvas2.width, canvas2.height);
    requestAnimationFrame(draw_2DCanvas);
}
draw_2DCanvas();

Now, the code is a lot longer, and the video element is called from a multitude of places.
To make the code more comprehensible I was planning on adding the video element on the page, with display:none or visibility:hidden and getting the element via the ID every time I need it.

But this is a very heavy page already, and I was wondering if adding the element on the page itself had any kind of impact?
I tried it, but couldn't notice if anything changed.

0 Answers
Related