It uses CMC(I:c) color differencing algorithm to procedurally generate a set of visually-distinguishable colors. Actually 92 different colors are precomputed and only used when needed.
Download tinycolor.js or install it with bower:
bower install spini/unique-colors
Then just include it in the page in a script tag:
<script src='(...)/unique-colors.js'></script>
Returns an array containing n different hex color codes (always the same ones).
Returns an array containing n different and shuffled hex color codes.