Asynchronous WordPress


Published on

WordCamp US Slide deck for the Asynchonous WordPress lightning talk.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Asynchronous WordPress

  1. 1. Aaron Brazell • @technosailor • A S Y N C H R O N O U S W O R D P R E S S O F F L O A D I N G H O O K E D E V E N T S TO I N C R E A S E PA G E S P E E D
  2. 2. Aaron Brazell • @technosailor • T H E P R O B L E M ( D R A M AT I C T H E M E M U S I C )
  3. 3. Aaron Brazell • @technosailor • • Every Time WordPress loads a page, events are fired. • Plugins typically hook events into init, admin_init, plugins_loaded, or save_post to fire events • Every event takes time to complete • Many dozens of events, all waiting to finish running, add overhead to WordPress.
  4. 4. Aaron Brazell • @technosailor • P O S S I B L E P R O B L E M S C E N A R I O S • External API Request (Facebook/Twitter? Mailkimp?) • Saving a Post • Requesting information about a user when a user is created.
  5. 5. - S O M E O N E W H O B A D LY M A N G L E D T H E Q U O T E “Asynchronous Events are not the heroes we want; they are the heroes we need.” Photo Credit: V Threepio, via Flickr, Creative Commons
  6. 6. T E C H C R U N C H A S Y N C L I B R A RY • TechCrunch had extremely long process times, particularly with their CrunchBase API. • API calls were required to repopulate cached results. • Eric Mann (@ericmann) and John Bloch (@johnpbloch) built a library to offload tasks to asynchronous equivalents • Runs on `shutdown` hook Photo Credit: Charlyn Wee, via Flickr Creative Commons
  7. 7. Aaron Brazell • @technosailor • O V E RV I E W O N H O W TO U S E • Bundle the WP_Async library in any theme or plugin and require it. It can also be installed as a standalone plugin. • Create a subclass that extends WP_Async_Task • Include a prepare_data() and run_action() method (Details in the documentation) • Include a protected $action variable that is set to the hook name you wish to run asynchronously. • Hook events on wp_async_{$action} (e.g. wp_async_transition_post_status)
  8. 8. Aaron Brazell • @technosailor • R E F E R E N C E S • TechCrunch Open Sources its WordPress Async Task Library: open-source-library/ • Asynchronous WordPress, by 10up: 2014/07/31/wp-async-task-our-new-open-source-library/ • Github: • Demo Plugin: • This Presentation: asynchronous-wordpress
  9. 9. Aaron Brazell • @technosailor • A A R O N B R A Z E L L • Sr. Web Engineer, 10up • We’re Hiring Project Managers, WordPress/PHP Engineers and Front End UX Engineers ( • Twitter: • Email: • Github: • Profile:
  10. 10. Aaron Brazell • @technosailor •