Conversation
supportThis plugin has a conflict with EventsManager (EM) plugin on the EM Booking page. Both Groups and EM use Selectize javascript to help with formatting content. EM uses the handle “em-selectize” whereas Groups does not specifically use a dedicated handle. It uses “selectize” alone. This is not a preferred coding practice, since it results in conflicts between the two plugins.
Tricky. Both plugins load Selectize for fields rendered, the issue is that EM loads a different set of plugins (for Selectize) than Groups, and when you visit the Events > Bookings page and Groups’ version is loaded first, then you will see a Javascript error complaining about Uncaught Error: Unable to find "click2deselect" plugin If the error causes any functionality you need on the pages to stop working and if you don’t need Groups’ access restrictions on Events, then you can simply disable access restrictions on Events by going to Groups > Options and under Access restrictions / Post types uncheck the entry for Event and hit Save. The issue here is not the use of one or another specific handle for Selectize, it’s the fact that both plugins rely on Selectize to render certain fields and each comes with its own version of Selectize and its particular configuration. If there are any suggestions on how to approach this issue, I’d be happy to hear those.
The primary reason for prefixing is to prevent a conflict in the use of different versions of the js library. If Plugin A uses plugin-a-selectize and Plugin B uses plugin-b-selectize, WordPress sees them as two distinct scripts, even if they happen to load the same underlying library file. This avoids errors caused by trying to register the same handle twice. Prefixed handles (e.g., em-selectize, woocommerce-selectize, my-plugin-selectize) make it immediately clear which plugin or theme registered the script. A generic handle like selectize is ambiguous. Which plugin loaded it? Which version is it? If multiple plugins try to register the same generic handle, only the first one typically succeeds (or it might cause errors depending on how they coded it), potentially leading to version conflicts where one plugin gets an older/newer version than it expects. In a perfect world, if multiple plugins need Selectize, they would ideally check if a compatible version is already registered (perhaps using the generic selectize handle, or even a prefixed one they know about) before registering their own. If found, they’d just use the existing one (by declaring it as a dependency). If not found, they would register it, preferably with their own unique handle (em-selectize). While using specific handles like em-selectize avoids handle name collisions, it doesn’t inherently solve the problem of loading the same library code multiple times if another plugin loads it under a different handle (selectize in the case of Groups). Both versions might get loaded into the browser, increasing page weight and potentially causing JS conflicts if they interact poorly. A “best” practice for plugins bundling common third party libraries involves using wp_script_is() to see if the library (under any known handle, generic or specific) is already registered or enqueued. If a compatible version exists, declare it as a dependency rather than enqueueing a duplicate copy. If the library isn’t already loaded, register and enqueue it using a unique, prefixed handle (like em-selectize).
Changing the handle will not make a difference in this case: The issue here is not the use of one or another specific handle for Selectize, it’s the fact that both plugins rely on Selectize to render certain fields and each comes with its own version of Selectize and its particular configuration. We could change ‘selectize’ to ‘groups-selectize’ but both plugins would still load their own version, assume their desired configuration and the issue would persist.
Tricky. Both plugins load Selectize for fields rendered, the issue is that EM loads a different set of plugins (for Selectize) than Groups, and when you visit the Events > Bookings page and Groups’ version is loaded first, then you will see a Javascript error complaining about Uncaught Error: Unable to find "click2deselect" plugin If the error causes any functionality you need on the pages to stop working and if you don’t need Groups’ access restrictions on Events, then you can simply disable access restrictions on Events by going to Groups > Options and under Access restrictions / Post types uncheck the entry for Event and hit Save. The issue here is not the use of one or another specific handle for Selectize, it’s the fact that both plugins rely on Selectize to render certain fields and each comes with its own version of Selectize and its particular configuration. If there are any suggestions on how to approach this issue, I’d be happy to hear those.
The primary reason for prefixing is to prevent a conflict in the use of different versions of the js library. If Plugin A uses plugin-a-selectize and Plugin B uses plugin-b-selectize, WordPress sees them as two distinct scripts, even if they happen to load the same underlying library file. This avoids errors caused by trying to register the same handle twice. Prefixed handles (e.g., em-selectize, woocommerce-selectize, my-plugin-selectize) make it immediately clear which plugin or theme registered the script. A generic handle like selectize is ambiguous. Which plugin loaded it? Which version is it? If multiple plugins try to register the same generic handle, only the first one typically succeeds (or it might cause errors depending on how they coded it), potentially leading to version conflicts where one plugin gets an older/newer version than it expects. In a perfect world, if multiple plugins need Selectize, they would ideally check if a compatible version is already registered (perhaps using the generic selectize handle, or even a prefixed one they know about) before registering their own. If found, they’d just use the existing one (by declaring it as a dependency). If not found, they would register it, preferably with their own unique handle (em-selectize). While using specific handles like em-selectize avoids handle name collisions, it doesn’t inherently solve the problem of loading the same library code multiple times if another plugin loads it under a different handle (selectize in the case of Groups). Both versions might get loaded into the browser, increasing page weight and potentially causing JS conflicts if they interact poorly. A “best” practice for plugins bundling common third party libraries involves using wp_script_is() to see if the library (under any known handle, generic or specific) is already registered or enqueued. If a compatible version exists, declare it as a dependency rather than enqueueing a duplicate copy. If the library isn’t already loaded, register and enqueue it using a unique, prefixed handle (like em-selectize).
Changing the handle will not make a difference in this case: The issue here is not the use of one or another specific handle for Selectize, it’s the fact that both plugins rely on Selectize to render certain fields and each comes with its own version of Selectize and its particular configuration. We could change ‘selectize’ to ‘groups-selectize’ but both plugins would still load their own version, assume their desired configuration and the issue would persist.