question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Single JSON file containing shortcodes

See original GitHub issue

This is a small feature request, and I totally understand if it’s out-of-scope for the project.

As of emojibase-data v6, the data.json file and shortcode file need to be stitched together to have both the shortcodes and emoji data in the same file (#64).

However, for my own use case (https://github.com/nolanlawson/emoji-picker-element/issues/47), having a single file was a nice convenience. By default, the library just fetches the JSON from jsdelivr (this is designed for folks not using a build step). Switching to multiple files is possible, but pushes complexity either to me or my consumers (or both).

To ease the process of upgrading from v5 to v6, perhaps a new JSON file could be added – call it data-with-shortcodes.json – which just includes the default Emojibase shortcodes? This would provide the most direct upgrade path to v6, while also allowing users to stitch together the files themselves if they prefer some other shortcode set.

I can only speak for my own library, but this would definitely help with the upgrade process. 🙂 Thanks for creating emojibase!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nolanlawsoncommented, Sep 28, 2020

Thanks for your response. Using LocalStorage/SessionStorage is a reasonable approach, but I’m avoiding it because 1) it’s synchronous, 2) accessing it means reading the entire emoji database into memory, and 3) accessing it also means running JSON.parse on the entire database. My technique is to use IndexedDB, so that all the querying can be done asynchronously, avoiding these costs on subsequent page load. Some details here.

I agree that in HTTP/2 having one additional network request is not a huge deal. I may look into caching the two ETags separately, or writing a small npm package to stitch the files together and publish the result.

Thanks again for creating emojibase! I appreciate all the hard work you’ve put into this, and dealing with users with very meticulous demands. 🙂

0reactions
milesjcommented, Sep 22, 2020

Yeah sorry, I have no plans of merging shortcodes back into the primary dataset for 2 reasons.

  1. The old shortcodes were the biggest complaint about emojibase, as they did not align with GitHub/Slack/Discord – all 3 of which are different from each other. I no longer want to force certain shortcodes on the consumer, as they should choose which preset they want.
  2. Removing shortcodes reduced all dataset file sizes by quite a lot.

I’d argue that multiple HTTP requests is a non-issue, as the browser/fetch is rarely the bottleneck. I avoid subsequent requests by caching the response in local/session storage (https://github.com/milesj/emojibase/blob/master/packages/core/src/fetchFromCDN.ts#L46). I would suggest doing something similar, coupled with your ETag implementation, and maybe supporting a shortcodesSource setting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loop json data within shortcode #1751 - 11ty/eleventy - GitHub
Hi guys! I am trying to feed shortcodes with json data from /data/_calendar.json. The calendar shortcodes will be used in numerous places ...
Read more >
How to: First Shortcode with JSON Content Importer - YouTube
See how simple it is to get data out of a JSON -feed into Wordpress with the help of the free JSON Content...
Read more >
How to add fontawesome shortcodes in a JSON File
I wanted to know how I can add font-awesome shortcodes in a JSON file and fetch it in React? I added like this...
Read more >
Docsy Shortcodes
Use Docsy's Hugo shortcodes to quickly build site pages.
Read more >
Adding json as params to shortcode
You could create a shortcode with only one attribute and that attribute could be the ID of a custom post type or the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found