• I’m the guy who digs into code of plugins very often and identifies all the glitches and bad design decisions to improve performance.

    But what I found here: I couldnt trust my eyes.

    For every single page load a user does on your page, this plugin does an AJAX call (which in fact means it initializes the whole WP setup a second time in the background including DB connection etc) just to fetch a single option from the DB (which they could just output at the first pageload).

    So in fact, page load will double because of this INSANE fail of design.

    Luckily, you can alter the AJAX URL to a non existing one which leads to a fail of AJAX call (i.e. the ajax call will not hit your server again).

    add_filter( 'wp_dark_mode_json', function($localize_scripts)
    {
    $localize_scripts['ajax_url'] = 'any non existing URL here...';
    $localize_scripts['url']['ajax'] = 'any non existing URL here...';
    return $localize_scripts;
    }, 10, 1);

    • This topic was modified 3 weeks, 4 days ago by sx1001.
Viewing 1 replies (of 1 total)
  • Plugin Support Toukir Hossain

    (@toukirwpdev)

    Thank you for your raise, your concern is valid and we’re taking your feedback to improve our product.

    Some technical decisions have been made intentionally to solve some contingency problems with diverse technology. Here we’d like to share some insights from our developers.

    We had to keep both ajax_url and url.ajax_url to keep compatible with the older version of WP Dark Mode Ultimate. In the near future, we’ll keep only one which is URL. ajax. Plugins, including WordPress, and even PHP have a lot of deprecated functions/classes themselves. Removing them without a semi-long transition period may break other systems. We’ll remove deprecated keys soon.

    We agree that we have both ways to fetch settings from Inline Script and Ajax (though only one option) because of the diversity of technology. This is not accidental, we had to do it intentionally for a real reason. Inline Script is mainly affected by server-side caching plugins. As it’s a printed JavaScript Object under content type text/HTML, it will always return a cached version of the object to all its visitors. So technically it’s not possible to check if the cache should be bypassed or not without making an extra Ajax Request to the server. Because Ajax and REST APIs are served dynamically, they are not affected by server-side cache technologies and they are not serving the same result for all users.

    In this case, Dark Mode will fetch cache-free settings from Ajax only for a single option to check if it’s required to Apply Dark Mode on the client side or not. We could have fetched all the settings through Ajax, it would have required extra queries. The plugin will only fetch a single option asynchronously to keep it lightweight. Asynchronous HTTP request doesn’t let you feel blocked from rendering your webpage.

    This Ajax request is not for everyone, it’s feature-specific. It’s being triggered after all the contents, components, and assets are fully loaded and executed to reduce any performance compromisation. Also, registering an Ajax hook in the backend will not be executed until it’s called from the client side.

    We’re strictly following PHP Coding Standards, along with WordPress Coding Standards, WordPress Community Standards, and Guidelines to keep the plugin free from bad practices. Still, we may make mistakes so we’re open to taking advice, suggestions, and feedback from our beloved users to improve our product. It’s you who are stakeholders of WP Dark Mode, and we’ll always prioritize your requirements and your needs. We’d like to inform you that we’re actively working on WP Dark Mode’s performance, optimization, and algorithmic applications to reduce memory consumption, and resource allocation as well as improve its performance. We’re hoping to release a version with performance very soon.

    We appreciate your understanding!

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this review.