CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Tip for speeding up Civi in WordPress
Pages: [1]

Author Topic: Tip for speeding up Civi in WordPress  (Read 583 times)

krypto

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 5
  • IT guy for @bhahumanists. Running Civi on WP.
    • British Humanist Association
  • CiviCRM version: 4.5.8
  • CMS version: WordPress 4.x
  • MySQL version: 5.5.x
  • PHP version: 5.5.x
Tip for speeding up Civi in WordPress
February 07, 2014, 08:08:35 am
Quick version
If you're running a WP site with a lot of plugins, you may be able to speed up Civi a *lot* by turning off plugins for ajax requests. You can do this by hacking the 'Plugin Organizer' plugin.

Long version
We run a pretty hefty WordPress site, with a bunch of plugins that cumulatively slow down page load times. As Civi is obviously running on top of WP, these plugins get loaded on every Civi page. So for us an average Civi page has roughly 2s of waiting time before we start receiving data. This isn't too painful, and there isn't much we can do about it - but I finally realised it's applying to every ajax page request too.

On the dashboard, say, Civi is making requests to /wp-admin/admin.php?page=CiviCRM&q=civicrm/ajax/dashboard&op=get_widget&otherstuff. So every one of these is coming with a 2s lag time for plugin processing that's not really needed. We eventually figured out a way to turn off plugins for these pages.

We use a WP plugin called Plugin Organizer: http://wordpress.org/plugins/plugin-organizer/. It can disable plugins for particular pages. Ideally we'd want to detect anything with 'q=civicrm/ajax' in it, but sadly it's not clever enough to detect querystring stuff like that. But you can hack it so it does: edit PluginOrganizerMU.class.php, and there's one massive while loop in there that's handling all the plugin-detection. Add this immediately before it:

Code: [Select]
if (
(strpos($this->requestedPermalink,addslashes('q=civicrm/ajax/')) !== false)
) {
$newPluginListAjaxOnly = array();
$newPluginListAjaxOnly[] = 'civicrm/civicrm.php';
return $newPluginListAjaxOnly;
}

(apologies for my amateur coding).

This detects any ajax page request and tells the page to only load the Civi plugin and nothing else. We later added another line to detect 'snippet=' as well.

Everything ajaxy is basically a joy, now. The quicksearch actually searches in realtime, the dashboard widgets appear quickly, the activities tab doesn't take forever to populate - everything's just much, much snappier. I can't even tell you how much nicer it is to use.

There are undoubtedly more elegant ways to do this. But this works, so I thought I'd share :-) Hope someone finds it useful.
« Last Edit: February 07, 2014, 08:14:59 am by krypto »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Tip for speeding up Civi in WordPress

This forum was archived on 2017-11-26.