What are the nature of the two extensions? If it makes sense, you could make one of them depend on the other (by specifying in the require
section of composer.json
). And then Twemoji would only need to be included in the parent one.
You could also make a third extension which only includes the Twemoji library, and make the other two depend on that. This is less desirable, though, since it creates noise. Also, while Composer will prevent an extension from being installed without its dependencies, Flarum doesn't currently check for dependency extensions to be enabled yet.
Or, finally (this is probably the best solution): You could load the Twemoji library dynamically instead of compiling it into your extension JS.:
if (!window.twemoji && !window.loadingTwemoji) {
var script = document.createElement('script');
script.src = 'twemoji';
document.head.appendChild(script);
window.loadingTwemoji = true;
}