Wonder if is possible do a Color Quantization plugin to be applied in a layout/layer or sprite.
Here are some of the best ones i found that already have a javascript port:
NeuQuant
https://www.npmjs.com/package/neuquant-js
K-Means
https://www.npmjs.com/package/kmeans-js
What you think? Is possible?