• Resolved PeterWillard

    (@peterwillard)


    Hello and thank you for the great plugin! Perchance you can provide some insight into my problem. I am struggling to optimise a website and am trying to reduce the number of requests. I am bundling all javascript into a single file. When Advanced Mode is enabled (I need to be able to inline SVGs) the plugin not only includes its js in the footer (as expected) but makes WordPress enqueue jquery.js as well. I am using my own jquery in my bundle so the additional one is a problem. So can you think of a way to keep inline SVG functionality, include the plugin js manually and not trigger the additional jquery enqueue? Thanks in advance for your time

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Hey,

    Glad you like the plugin 😃

    Sounds like you’d need to modify my plugin where the JS is enqueued and remove the jQuery dependency from that line… it’s not something I would likely provide an option for in the settings because it’s usually considered bad practice to include your own version of jQuery.

    I hope this makes sense.

    Plugin Author Benbodhi

    (@benbodhi)

    Hey I just had a thought, can’t believe I didn’t think of it already!
    You can easily dequeue my JS and then enqueue it again using your own code in your child theme. Just make sure to enqueue without the jQuery dependency.

    Thread Starter PeterWillard

    (@peterwillard)

    Hello again Ben!

    Please forgive the lack of response, this is a sideproject I am working on in my spare time and I have been absolutely swamped with my full time job lately.

    Anyway, the sub-par JS dev that I am, I figured this out. I dequeued the plugin script as per you suggestion with a simple

    function dequeue_svgs_script() {
        wp_dequeue_script('bodhi_svg_inline');
    }
    add_action( 'wp_print_scripts', 'dequeue_svgs_script', 100 );

    and then included the plugin code in my own as a service. I just had to declare cssTarget = "img.style-svg" and it worked. Thank you for your time and suggestions.

    Take care!

    Plugin Author Benbodhi

    (@benbodhi)

    Excellent news! I’m glad you got it sorted 😀

    Thanks for using my plugin. I hope the side project goes well.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Bundle plugin js to reduce requests’ is closed to new replies.