• on_edge

    (@on_edge)


    WordPress loads jQuery 1.11.0. I have a booking widget on a lodging site that requires jQuery 1.9.1. I’ve done a lot of searching and reading and know more than I did but I’m also more confused. How would I use 1.9.1 for the booking widget and allow everything else on the site to use the default 1.11.0?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Steve Grunwell

    (@stevegrunwell)

    The booking plugin most likely has 1.9.1 as a minimum version requirement, which means 1.11.0 (which is more recent than 1.9.1) should work just fine. Loading two versions of jQuery would a) force your user to download the library twice and b) can cause all kinds of conflicts (which tends to happen when multiple instances of jQuery are present).

    Thread Starter on_edge

    (@on_edge)

    Good thought, Steve. And one that occurred to me as well. The first thing I tried was making it work with 1.11.0. It doesn’t. I don’t like the idea of two versions, but it doesn’t seem like I have a choice.

    3 resources I found:
    https://sundropsoftware.com/how-to-use-jquery-noconflict-the-right-way/
    https://api.jquery.com/jQuery.noConflict/
    https://devotepress.com/wordpress-coding/how-to-properly-use-jquery-scripts-in-wordpress/#.VGWDIclNe1t

    The private variable mentioned in the first article seems to be the key. With WordPress, I’ve read that enqeue vs. head scripts are also desirable if not required.

    WP loads jquery in noConflict mode, which is supposed to avoid this issue. With both versions, I’ve made it work. But it also turns a 2-column section to a single column leaving a blank area in the middle of the page.

    This is the page in question: https://www.hydeawayinn.com/category/rooms/

    The top widget in the sidebar is the one. You can see it works, but the room items to the left are a single column instead of two. The site uses the Shoestrap (Bootstrap based) framework and a child theme for custom functions.

    Steve Grunwell

    (@stevegrunwell)

    What specific errors appear in your console (available in the Developer Tools in most browsers) when you try to only use 1.11.0? Loading multiple versions is causing an “Uncaught TypeError: undefined is not a function” error, which typically halts other scripts from executing (I’m guessing that’s why your columns are misbehaving as well, if scripts were re-sizing them to fit a grid).

    You’re correct that scripts should be enqueued via wp_enqueue_script, as this allows WordPress to manage dependencies and ensure that scripts are being loaded in the proper order (currently the script that’s failing is being loaded between the two versions of jQuery, but being executed after they (and thus, the page) is loaded, per the $j(window).load(...) call.

    Thread Starter on_edge

    (@on_edge)

    The Shoestrap developer said much the same and that I’d need to change some code in an includes file for the Gridder plugin (isotope/masonry).

    wp_enqueue_script( 'shoestrap_gridder_script', SHOESTRAPGRIDDERURL . '/assets/js/scripts.js' );
    
    replace it with
    
    wp_enqueue_script( 'shoestrap_gridder_script', SHOESTRAPGRIDDERURL . '/assets/js/scripts.js', array( 'jquery' ) );

    I tried this and it didn’t work. Still need to determine how I can get it to load first, I guess.

    Thread Starter on_edge

    (@on_edge)

    When I load only 1.11.1 I get this error in the console: TypeError: $ is not a function wrp_calendar.js:3

    This controls the datepicker calendar, which doesn’t work with 1.11.1

    Thread Starter on_edge

    (@on_edge)

    This leads me to believe that all instances of $ in the booking engine js should be changed to something else, but wrp_calendar.js lives on their server. I have no control over it.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to use a 2nd version of jQuery’ is closed to new replies.