This is the best implementation of getting random numbers, backed by the blockchain.
just add the script, and import it
<script type="module">
import random from 'https://cdn.rawgit.com/bullgit/fair-random/gh-pages/fair-random.js';
console.log(random(0,5));
</script>
This project was made as a workshop at CodePenDay 2017 in Hamburg, slides and video available here
WTFPL