I make a project and I need to update the image (transmitted from the client in base64 format) without refreshing the page. At the moment there is such a (shit) code, but when the image is updated, flickering occurs (you can see how it loads ... paradise for epileptic). How to do all this good without flickering? PS Python (nginx + flask) is used as a backend. PPS Yes, now it costs 1 second, but I would like to get to 0.1.
<script type='text/javascript'> const Http = new XMLHttpRequest(); const method_name = 'getframe'; const url='http://stream.std-567.ist.mospolytech.ru/'; function update(){ Http.onerror = function(){ //alert("something went wrong"); } Http.open('POST', url + method_name); Http.send(); function _base64ToArrayBuffer(base64) { var binary_string = window.atob(base64); var len = binary_string.length; var bytes = new Uint8Array( len ); for (var i = 0; i < len; i++){ bytes[i] = binary_string.charCodeAt(i); } return bytes.buffer; } Http.onload = function(){ Http.onreadystatechange=(e)=> { //console.log(); screenpanel.src ="data:image/png;base64," + Http.responseText; } } } setInterval(update,1000); </script>