Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

emojify.js

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emojify.js

A Javascript module to convert emoji keywords to images.

  • 0.9.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-57.17%
Maintainers
1
Weekly downloads
 
Created
Source

emojify.js

npm version Bower version MIT Licensed Gitter chat


MasterDevelop
Master branch build statusDevelop branch build status

Browser Results

A swiss-army-knife for all emoji, in Javascript. Used by Gitter

The emoji keywords are as described by emoji-cheat-sheet.com.

Go to this project's GitHub pages to see the code in action.

Features

  • Fast
  • Awesome
  • Made from unicorn blood
  • Available on a CDN (gasp)
  • Converts emoticons like :) :( :'(
  • Allows customisation of processed emoji
  • Includes a sample .htaccess file for caching Javascript and CSS
  • Switchable emoji sets (SOON!)

Installation

Via cdnjs [SOON]

Add this to the rest of your stylesheet imports: Then add this to your Javascript code:

Via Bower

bower install emojify.js#~1.0 --save

Via npm

npm install emojify.js#~1.0 --save

API

setConfig([object])

This works in the browser and on Node

Parameters
  • object - Optional JSON object with any of the following attributes:
OptionDefaultDescription
emojify_tag_typenullWhen set, emojify uses this element with the class emoji emoji-#{emojiname} instead of an img with a src attribute. Example valid values: div, span
only_crawl_idnullRestricts searching for emojis to a specified element & it's children. If null, and no object is passed to run(), document.body is used
img_dir'images/emoji'Defines the path to the emoji images
ignore_emoticonsfalseIf true, only convert emoji like :smile: and ignore emoticons like :)
ignored_tags{'SCRIPT': 1,'TEXTAREA': 1,'A': 1,'PRE': 1,'CODE': 1}A list of elements that you don't want emojified
Usage
emojify.setConfig({emojify_tag_type : 'div'});

run([element])

This only works in the browser

Parameters
  • element - Optional HTML element to restrict the emojification to.
Usage
emojify.run();
// OR
emojify.run(document.getElementById('my-element'))

replace(string, [callback])

This works in the browser and on Node

Parameters
  • string - String to emojify
  • callback - Optional callback function to output emoji with
Usage

By default, emojify.js uses the internal function defaultReplacer() to replace emoji. You can override this behaviour by supplying your own callback function.

Your callback function will receive two parameters, the emoji pattern found (emoji), and the emoji name (name). In the case of emoticons, for example, emoji = ':)' and name = 'smile'.

The context in which your replacer function is run will have the config available. So you can access properties such as img_dir at this.config.img_dir.

emojify.replace('I am happy :)');
// OR
replacer = function(emoji, name) {
    // Customise output here
    return emojifiedString;
}

emojify.replace('I am happy :)', replacer);

Excluding elements from being processed

To exclude tags from being emojified, add no-emojify to their class attributes.

Contributing changes

Please read CONTRIBUTING.md.

Keywords

FAQs

Package last updated on 02 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc