There are already webcams which do this- but they use a mime trick for 'multipart/x-mixed-replace'.
That's basically the server telling the client 'That data I just sent you, well now replace it with this new thing'.
No JavaScript needed, and can work with plain http and jpeg