• Resolved wouterdoorn

    (@wouterdoorn)


    Hi,

    during a performance check for our website I found that your plugin is very very heavy on resources. It causes about 70kb of js to be loaded and a 3.6kb css file as wel. The js specifically amounts to half of my total javascript load (jquery.min.js included). The files are also loaded on every single page, even when the shortcode is not loaded

    the js files that are loaded due to the plugin:
    polyfill.min.js
    query.validate.min.js
    modal.min.js
    kudos-public.min.js

    I really like your plugin, but this seems very excessive. Please consider optimizing the plugin.

    Best,

    Wouter

    • This topic was modified 3 years, 6 months ago by wouterdoorn.
    • This topic was modified 3 years, 6 months ago by wouterdoorn.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author iseardmedia

    (@iseardmedia)

    Hi Wouter,

    I am really glad you like the plugin and thanks for your suggestion.

    I have spent a lot of time optimizing this plugin, removing unnecessary css rules, reducing dependency on jQuery and using Webpack to minimize all the assets (js, css, images, fonts). Doing this while maintaining compatibility across different websites and browsers can be a tricky task, especially since older browsers do not support modern techniques and formats. For a comparison, embedding a single YouTube video will bring with it over 500kb of JavaScript and 50kb of css just to load the player.

    For compatibility reasons WordPress will often enqueue the wp-polyfill.min.js file to maximize compatibility, this is not something I recommended removing as it could break your website for some users.

    WordPress also insists that you do not bundle your external JavaScript libraries (micromodal, jquery.validate in the case of Kudos Donations) to ensure that these can be cached by browsers across websites so that users do not need to re-download them if they already have them.

    The reason that the resources are loaded on every page is because a modal can be shown on any page by using the custom return URL and therefore the resources need to be on hand to display it correctly. I am already looking into a way to prevent this in the future as I agree it is not ideal.

    Plans for future:
    – Remove jQuery as a dependency (not urgent since WordPress will still load this for now anyway).
    – Workaround for resources loading on pages where Kudos Donations is not present.

    However, while taking into consideration the points above I do consider this plugin to be very lean as it is.

    Please keep an eye out for updates.
    Mike

    Thread Starter wouterdoorn

    (@wouterdoorn)

    Hi Mike,

    thanks for the swift and extensive reply. I do appreciate al the work that you have put in which must have taken a lot of time, and really appreciate you offering it for free. So I hope my inquiry wasn’t to blunt. I’m only a hobbyist that made a website for a nonprofit foundation and I tend to get carried away with trying to optimize everything…

    In order to only load the css and js when necessary I tried using the following in functions.php in order to load the css and js in posts only, but it didn’t work, any suggestions?

    function kudos_deregister_javascript_css() {
    if ( !is_single() ) {
    wp_deregister_script( ‘kudos-public’ );
    wp_deregister_style( ‘kudos-public’ );
    }
    }
    add_action( ‘wp_enqueue_scripts’, ‘kudos_deregister_javascript_css’, 100 );

    And since your plugin is the only one on my website that is loading the wp-polyfill.min.js I could look into disabling it. As far as I can tell it is only need for IE support, and not needed for modern browsers. Is that true or am I missing something?

    Best,

    Wouter

    • This reply was modified 3 years, 6 months ago by wouterdoorn.
    Plugin Author iseardmedia

    (@iseardmedia)

    Hi Wouter,

    Please note that I cannot officially support using Kudos in this way, but I’m happy to show you how.

    You can use this to disable the loading of Kudos related scripts and styles on anything but single posts. Just a quick note, The non-kudos libraries (particularly jquery-validate) are fairly common and this could cause problems if you have other plugins installed that use them (and use the same handles for them).

    // Dequeue Kudos Donations assets
    add_action( 'wp_enqueue_scripts', function () {
        if ( !is_single() ) {
            wp_dequeue_script( 'kudos-donations-public' );
            wp_dequeue_script( 'micromodal' );
            wp_dequeue_script( 'jquery-validate' );
            wp_dequeue_style( 'kudos-donations-public' );
        }
    }, 100 );

    While IE is definitely a main reason for using polyfills, there are many other browsers that need them too, particularly older mobile browsers and Safari. Polyfills can also used to fix certain outstanding bugs even in modern browsers. It’s up to you to decide if supporting these browsers is necessary for your website, but I would ensure you thoroughly test everything after disabling it.

    Good luck,
    Mike

    Thread Starter wouterdoorn

    (@wouterdoorn)

    Thanks for your support!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Plugin is very resource heavy, please consider making it leaner’ is closed to new replies.