14

When visiting GitHub using a browser without color emoji support, it loads emoji glyphs as image files.

GitHub without color emoji support

But when visiting GitHub using a browser that does have color emoji support, it lets the browser render the glyphs normally instead.

GitHub with color emoji support

How can GitHub know whether the browser supports color emoji or not?

Jeremy Danyow
  • 26,470
  • 12
  • 87
  • 133
jobukkit
  • 2,490
  • 8
  • 26
  • 41

1 Answers1

1

I do that like this :

var canvas = document.createElement("canvas"),
    ctx = canvas.getContext("2d");

canvas.style="height:100px;width:100px;position:absolute;top:60%;background:white";
document.body.appendChild(canvas);
ctx.fillStyle ="#FFF";
ctx.font="100px Arial";
ctx.fillText('',100,100);
var d = ctx.getImageData(50, 50, 1, 1).data;
if (d[0] + d[1] + d[2] === 0) {
    //need twemoji or something else
} else {
    //nothing to do   
}
Kalamarico
  • 5,466
  • 22
  • 53
  • 70
bubbatls
  • 11
  • 1