@hiddenpearls
Thanks for quick reply. I noticed that too momentjs is the issue but changing the slug wouldn’t help. Keep the slug like sanitize_title e.g if it is moment.js It could be moment-js
Yes and no. The slug one uses to register and enqueue a script can be an issue… but it’s not the one I was talking about.
If we use the same slug, two different plugins (yours and ours) would “define” the same script (momentjs), but only one JS file would be printed in the HTML, because the last plugin that (re-)defines the script would overwrite whatever plugin was added by the other.
If we don’t use the same slug, then we wouldn’t overwrite each other’s scripts… in PHP. But we would definitely overwrite them in the browser. Using different slugs means that you’d be able to enqueue your script and I’d be able to enqueue mine. Both scripts define the global variable moment
, so whoever comes last, would be “overwriting” the other (or, if the script defines the global variable only if it doesn’t already exist, whoever comes first would have all the power).
We found that Conflict will be resolved if we change the momentjs version to 2.18 the latest release in our Analytify plugin.
The problem with momentjs is that there are multiple versions of the same script. With or without locales, with or without timezones. That’s when issues arise – if you use one version and I use the other.
As I said before, the only solution I could think of was to edit the script itself (the min.js
file) and change all moment
keywords to ncmoment
, creating a new global variable that wouldn’t collide with any of yours (or other plugins).
I hope this makes sense… ??
Regards,
David