Wordpress performance plugin

Hi,

Is there a way we can enhance wordpress's performance by able to load only the plugins on a particular page that are required? Like if a page 'Y' requires 6 plugins for all the functionality, only those 6 plugins are loaded and not the entire bunch of 10. I think because wordpress loads every activated plugin on every single page, it becomes very slow at times. Companies have Caching plugins but i am suggesting something intelligent that calibrates what plugin set is required and uses that information for performance enhancements.

Please let me know if its a direction people can work on.

  • Gabe

    Plugins can be coded so that scripts and CSS are only loaded on the page if they're required. I'm not sure if a plugin could do that consistently and in all edge cases, but I assume it'd be possible to build something like that which works for most plugins.

    Personally, I minimize the plugins I use and customize the ones that have issues (usually by moving the enqueue CSS/JS lines), so that might be a temporary solution for you. This tends to be less effective for plugins that are updated fequently.

    Every extra request has some effect, but as long as you're not crazy with the plugins things shouldn't be too bad since the JS/CSS are cached on the first page load.

    Rather than building a plugin that 'intelligently' decides which plugins (essentially CSS/JS) to load, you're better of using a service like Google PageSpeed or an advanced caching plugin like W3TC to combine and minimy CSS and JS. By combining and minifying style sheets and scripts, you only have to load it once for all pages anyway. Again, it's not a perfect solution but assuming this doesn't exist already I don't think it'd be worth the developing as there are other solutions that 'good enough' and almost as effective if not moreso. Hope this helps.

  • Mindblaze

    Thank you Gabe and Patrick for your suggestions.

    Actually its not only JS and CSS i am talking about. I want the plugin to be able to decide which plugins to load on a particular page. That includes the execution of PHP files and DB requests etc. On every page, wordpress usually does a 1000 queries from the DB and generates all those objects and arrays. I want to be able to somehow reduce all that and load it only when necessary. If its done properly i am assuming it would make the WP performance more than 10x faster don't you agree?

    I am aware that wordpress uses temporary transients for most of the data but its still too much. This makes it very hard to scale wordpress.

  • Gabe

    I don't agree completely. What slows down most websites with too many plugins/poorly coded plugins are the extra http requests and inefficient loading of CSS, JS, etc. Assuming a plugin is coded well, aside from JS/CSS a plugin doesn't add *much* more.

    In fact it's almost like it were just part of the theme or something, it's executed the same way. If your DB is massive, then the unnecessary queries could slow you down, but it's typically not a huge issue. If it were, we'd see a lot more people hardcoding (where able) all PHP queries like <?php get_site_url(); ?> and other generic, easily replaceable queries, often found in theme files (particularly in headers). I used to do this, but it's not worth the time unless you're really running out of things to optimize.

    Most times there's plenty of other low hanging fruit in terms of things to optimize like http requests (eliminating extraneous scripts and style sheets), optimizing images, using better (or rewriting shitty) plugins, etc.

    I'd say 10x faster is a huge stretch unless you have a massive DB or your server is a POS. By reducing queries in the way you describe you're more likely to see a 1.01x increase...maybe 1.1x if you have a 50+ plugins. 10x means you'd go from a 10sec load time to a 1sec load time just by optimizing/removing DB queries...which is doubtful. Optimizing images/JS/CSS yes...optimizing a DB? Doubtful.

    Are you talking about writing this plugin for others to use or just for your own website? Maybe you'd get traction if other people want it (I'd test demand first). If it's just for you, I'd put it on the backburner. As a developer/designer/startup founder you have more important things to do than try to minimize/optimize DB queries. Besides, until you're making a few thousand (preferably $10k+) a month revenue from a project it's probably more premature optimization than anything else. Until then it's better to stick with stuff that gives you the biggest returns. DB queries only become a big deal at scale.

  • Mindblaze

    Thanks for such a detailed overview.

    Gabe have you used codeigniter ? Its a PHP framework. The cool thing about it is that it's super fast. It loads stuff on pages where it is required. It doesn't even provide a default DB connection. If you need it, you load the connector.

    So what i am actually saying is if it is possible to write a plugin that optimizes wordpress plugin loads by limiting only the required plugin to load on that page. For example, a page 'X' requires 4 plugins out of the activated 10. It only loads the data from those 4 plugins. That means JS, CSS, Images, PHP execution and class declarations, filters, actions and DB operations for those 4 plugins only.

    I feel that wordpress is rather heavy on the server when its DB or number of plugin gets more and more.

    So my suggestion is something like this:

    There is this Super plugin that sits on top of all the plugins and it monitors them. It sees what request the user made and allow access to those particular plugin set and avoid everything else. Then maybe for a different request, it loads different set of plugins (depending on the page requested).

    I am just thinking out load. I don't have any plans ironed out, rather wanted to know if its even possible to make something like this. Maybe wordpress themselves later add this functionality as their system is getting bulkier and bulkier with each new release.

  • Gabe

    I haven't used Codeigniter, it sounds Interesting though. I don't know enough about WordPress' core to say either way. It's a neat concept though. The thing is that I don't know how much it'd matter since only the first page view would use it. After that, cached versions would be delivered since even queries can be cached. I guess it's possible, but for it to be effective it'd have to be more than a simple plugin.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.