New Plugin: Relative Time with Moment.js

Did you ever add the diff function?

Hi @JayM , no I didn’t - not enough demand for it and like I stated previously, it’s not really a good fit for this plugin in my opinion. There are now a few other plugins based on moment.js - perhaps one of them includes this function.

1 Like

Hey @louisadekoya,

I just found out (after a whole day tracking down the issue) that your plugin, if placed on the same page, or even a Reusable Element on the same page as the Air Calendar Plugin it breaks it.

Any thoughts about why it would create such a conflict with it?

Trying to load moment twice can cause issues. It’s the backbone library for the plugin plus the calendar plugin you mentioned in the other forum post.

@ZeroqodeSupport couldnt you run a check prior to loading the moment scripts? Assuming that’s the issue. I could be way off base here but I’ve seen this before.

You can check for the existence of the <script>tag in question by selecting all of the <script>elements and checking their src attributes:

//get the number of `<script>` elements that have the correct `src` attribute
var len = $('script').filter(function () {
    return ($(this).attr('src') == '');

//if there are no scripts that match, the load it
if (len === 0) {
    $.getScript('<external JS>');

Check for the script ^^^

If not present, append it!

let myScript = document.createElement("script");
myScript.setAttribute("src", "");

I ran into this issue earlier today

@zavitac and @jared.gibb,

This came up before with one of the chart plugins that was also using moment.js and I ended up adding some code (if (!window.moment) …) to my plugin to only load moment if not already loaded. It seemed to work at the time for the people that had the issue and I assume it still does.

I think the other plugins using moment need to do something similar because if they attempt to load moment after my plugin has already done so, the conflict will occur regardless of what my plugin does.

By the way, @jared.gibb, if I’m not mistaken, your sample code will only match the particular version of moment.js that you’ve stated and won’t catch cases where a different version is used.

For reference, here’s where I found the method I adopted to test for moment.


Good point! I use the same version in Wagons. That’s great source that code from but I had originally grabbed it from stackoverflow.

Nice catch and thanks for the fix!

Ugh this is getting really close to DLL Hell. What happens if another (usually unmaintained) plugin pulls in an incompatible or older version missing key features? This won’t be such a big problem with Moment because it is effectively frozen. However I can see plugins knocking each other out with references to other more actively maintained modules.

1 Like

Hello, @jared.gibb
Thanks for mentioning us in this thread.

We’ve taken into consideration the possibility to improve the Air Calendar Plugin, and especially loading the Moment, for future updates. Thanks for that! :slightly_smiling_face:
Also, thank you for providing additional information regarding the scripts :pray:

We will notify all our users regarding the upgraded version of the plugin, where the mentioned point will be fixed.
Best regards,
Zeroqode Support Team

Hello, any chance to translate the strings in different languages?

Thank you

Hi @agence.webinti,

You should try the ‘locales’ version of the plugin - Relative Time (Locales) - Moment.js Plugin | Bubble

1 Like

Thanks a lot its perfect!

1 Like

Сan you please share this editor’s link for view-only?

Hi! I am having a problem right now with relative time with moment.js plugin, where instead of displaying the time, the timestamp input on the chat bubble displays “loading…” and never loads eventually. Everything used to work before but suddenly stopped working, even though we did not make any changes. Here is the error from the console: “DevTools failed to load source map: Could not load content for HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE”. What could cause this?

Hi @oshevchuk,

I’m sorry that you’re having some trouble. The plugin hasn’t been changed. Is it possible that you have installed another plugin on the page since it last worked? I can tell you that the console error you have referenced is not from the relative time plugin. It looks like it relates to feather icons. I suggest duplicating your page and removing other plugin elements one at a time to isolate the issue. Another thing is to check if that the plugin element is visible before you try to use its output.

Hey @louisadekoya

I hope you’re doing well. I wanted to bring up an issue I’ve been experiencing with the Relative Time plugin. Instead of displaying values like “2 hrs ago,” it seems to be stuck on “loading…”

I’ve checked my settings and configurations, but the problem persists. Has anyone else encountered this issue or found a solution? Your insights would be greatly appreciated!

Thanks in advance for your help.

Hi @simeontechguru ,

Someone did report a similar problem a while back and it was because privacy rules made the data (input to the plugin element) unavailable. You get this loading state when the element does not receive a text element that it can read, which can happen when what is being passed to it is empty or does not evaluate to a text, for whatever reason. I hope this helps.

Hi i tried using the plugin but nothing shows up when i preview it


is it because it doesn’t show up in view mode?

Hi, you have to place something like a text element on the page to reference and show the plugin element’s output.

ok thanks got it