• Resolved Imagemc001

    (@mc001)


    Hi,

    We have a need to run a couple of commercial plugins, both of which depend on the same Javascript library but of very different vintage. Hence, one cannot just get one plugin to use the other’s bundled library as the versions used differ by the major release. To be specific, the common library in question is the DataTables JS library, with one using version 1.12.1 and the other 2.1.5, but these details are an aside to the actual principle in question. Historically we have developed our own plugins which were themselves based on the plugin using the older version of DT, but now need to develop against the other one, and which lead to API clashes. All these plugins need to run simultaneously on the same host. Has anyone here ever been in a similar situation, and if so what strategies have been used to get around the problem?

    Thanks for any help!

    mc

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Imagethreadi

    (@threadi)

    Please contact the support team for the commercial plugins you use. I would recommend contacting the support of the plugin that uses the older version. They should make an update here. Also describe your problem with compatibility. They may also offer a way to deactivate the integration.

    Please note that we cannot help you with commercial products here in the forum.

    Thread Starter Imagemc001

    (@mc001)

    Thanks for replying. I understand that you can’t help with specific plugins, but I was interested in the general problem of having to support two versions of the same JS library, immaterial of their origin.

    Moderator Imagethreadi

    (@threadi)

    In general, it can of course be said that the double integration of the same libraries is totally unfavorable. The effect of this depends on the library itself and cannot be answered in general terms. In the worst case, it leads to a general JavaScript error that affects the output of the website in the frontend. As I said, this is not so easy to solve if the cause is 2 different plugins.

    Thread Starter Imagemc001

    (@mc001)

    In case anyone runs into the same issue, we’ve solved the problem by using something like:

    function dte_selective_js_loading() {
    $allowed_pages = [ 'page1', 'page2' ] ;

    if ( is_page( $allowed_pages ) ) {
    wp_register_script('cri_DTE_1', '/path/to/datatables.min.js'), array('jquery'), '1.0.0', true);
    wp_enqueue_script('cri_DTE_1');
    }
    }
    add_action( 'wp_enqueue_scripts', 'dte_selective_js_loading' );

    That $allowed_pages is a list of slugs of pages where we want the newer JS library (that datatables.min.js being registered) to be used, with the older version being used elsewhere by default. So far it’s passed all our tests, and though we realise that this solution is not ideal since we have to keep that list up to date, we deem it a reasonable cost for the constraints placed on us. Furthermore, we expect to eventually replace the use of the older library, whence we would then be able to dispense with this approach anyway.

    • This reply was modified 8 months, 1 week ago by Imagemc001.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Running different versions of the same JS library’ is closed to new replies.