# Twitter Emoji (Twemoji) [![Build Status](https://travis-ci.org/twitter/twemoji.svg?branch=gh-pages)](https://travis-ci.org/twitter/twemoji) A simple library that provides standard Unicode [emoji](http://en.wikipedia.org/wiki/Emoji) support across all platforms. ## Unicode 8.0 and Diversity The **twemoji V2** adheres to the [8.0 Unicode version](http://unicode.org/versions/Unicode8.0.0/) and **supports** 1661 different emoji, including **[diversity](http://www.unicode.org/reports/tr51/#Diversity)**. The previous twemoji V1 adheres to the [7.0 Unicode version](http://www.unicode.org/charts/PDF/Unicode-7.0/U70-1F300.pdf) and supports 872 different emoji. ## Version 2 CDN Support The folks over at [MaxCDN](https://www.maxcdn.com) graciously provide CDN support for both version 1 and version 2. For the latter one, use the following in the `
` tag of your HTML document(s): ```html ``` ## Breaking changes in V2 _TL;DR_: there's no `variant` anymore, all callbacks receives the transformed `iconId` and in some case the rawText too. There are few potentially breaking changes in `twemoji` version 2: * the `parse` invoked function signature is now `(iconId, options)` instead of `(icon, options, variant)` * the `attributes` function will receives `(rawText, iconId)` instead of `(icon, variant)` * the **default** remote protocol is now **https** regardless the current site is _http_ or even _file_ * the **default** PNG icon size is **72** pixels and **there are no other PNG assets** for 16 or 32. * in order to access latest Unicode 8 ready assets you need to specify *folder* `2/72x72` or `2/svg`. Everything else is pretty much the same so if you were using defaults, all you need to do is to add the version `2/` before the `twmoji.js` file you were using. ## Version 1 CDN Support The folks over at [MaxCDN](https://www.maxcdn.com) graciously provide CDN support. Just use the following in the `` tag of your HTML document(s): ```html ``` Alternatively you can use [cdnjs](https://cdnjs.com/) if you prefer: ```html ``` ## API Following all methods exposed through the `twemoji` namespace. ### twemoji.parse( ... ) V1 This is the main parsing utility and has 3 overloads per each parsing type. There are mainly two kind of parsing: [string parsing](https://github.com/twitter/twemoji#string-parsing) and [DOM parsing](https://github.com/twitter/twemoji#dom-parsing). Each of them accept a callback to generate each image source or an options object with parsing info. Here is a walk through all parsing possibilities: ##### string parsing (V1) Given a generic string, it will replace all emoji with an `` tag. While this can be used to inject via `innerHTML` emoji image tags, please note that this method does not sanitize the string or prevent malicious code from being executed. As an example, if the text contains a `