Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to use Twemoji in your site.

Step 1: Add the Twemoji library to your <head> tag.

<!DOCTYPE html>
<head>
+ <script src="https://twemoji.maxcdn.com/v/latest/twemoji.min.js" crossorigin="anonymous"></script>
</head>
...

Step 2: Add the parser script after the closing <body> tag.

...
</body>
+ <script>
+ document.getElementsByTagName("body")[0].innerHTML=twemoji.parse(document.getElementsByTagName("body")[0].innerHTML)
+ </script>
</html>

Step 3: Adjust some CSS to fix the large emoji issue. Adjust as needed.

img.emoji {
   height: 1.1em;
   width: 1.1em;
   margin: 0 .05em 0 .1em;
   vertical-align: -0.1em;
}

Twemoji is now installed on your site! Enjoy!

Note: Emoji's will only be parsed in the <body> tag so it does not mess up stuff like metatags.

Demo: https://awesomenotebook.glitch.me/posts/2020-11-4-twemoji-support-test/

Noobs looking at this, you don’t need to include the plus signs. - CarlyRaeJepsenStan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.