Skip to content

Instantly share code, notes, and snippets.

@mathisonian
Created December 10, 2013 03:24
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathisonian/7885295 to your computer and use it in GitHub Desktop.
Save mathisonian/7885295 to your computer and use it in GitHub Desktop.
Detect emoji support
/**
* Determine if this browser supports emoji.
*
* Modified from https://gist.github.com/mwunsch/4710561
* and probobly originally github's javascript source
*/
function doesSupportEmoji() {
var context, smiley;
if (!document.createElement('canvas').getContext) return;
context = document.createElement('canvas').getContext('2d');
if (typeof context.fillText != 'function') return;
smile = String.fromCharCode(55357) + String.fromCharCode(56835);
context.textBaseline = "top";
context.font = "32px Arial";
context.fillText(smile, 0, 0);
return context.getImageData(16, 16, 1, 1).data[0] !== 0;
}
@nok
Copy link

nok commented Aug 16, 2017

var context, smiley; should be var context, smile;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment