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!