Skip to content

Instantly share code, notes, and snippets.

@dansimau
Created March 5, 2014 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dansimau/9364842 to your computer and use it in GitHub Desktop.
Save dansimau/9364842 to your computer and use it in GitHub Desktop.
Instantly add emoji to any web app.
<script src="https://raw.github.com/hassankhan/emojify.js/master/emojify.min.js"></script>
<script>
(function() {
// Config
emojify.setConfig({
img_dir : '/emoji',
ignored_tags : {
'SCRIPT' : 1,
'TEXTAREA': 1,
'A' : 1,
'PRE' : 1,
'CODE' : 1
}
});
// Run emojify on page load
$(document).ready(function() {
emojify.run();
});
// Re-run emojify on DOM changes
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
// Go through list of changed objects and re-emojify
mutations.forEach(function(mutation) {
emojify.run(mutation.target);
});
});
observer.observe(document, {
subtree: true,
characterData: true,
childList: true
});
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment