there is already established tech to solve these problems, webtorrent is meant for p2p but browsers are not, mafintosh the creator of webtorrent has largely given up on browsers and is now running this company called holepunch making pear and keet, there is no other p2p codebase getting more dev on in the last 3 years and the results show