Asynchronous WordPress

6,441 views

Published on

WordCamp US Slide deck for the Asynchonous WordPress lightning talk.

Published in: Engineering
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
6,441
On SlideShare
0
From Embeds
0
Number of Embeds
4,377
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Asynchronous WordPress

  1. 1. Aaron Brazell • @technosailor • www.technosailor.com 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 • www.technosailor.com 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 • www.technosailor.com • 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 • www.technosailor.com 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 • www.technosailor.com 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 • www.technosailor.com R E F E R E N C E S • TechCrunch Open Sources its WordPress Async Task Library: http://techcrunch.com/2014/07/31/wp-async-task-our-new- open-source-library/ • Asynchronous WordPress, by 10up: http://techcrunch.com/ 2014/07/31/wp-async-task-our-new-open-source-library/ • Github: https://github.com/techcrunch/wp-async-task/ • Demo Plugin: https://github.com/technosailor/wcbalt-async-wp • This Presentation: http://www.slideshare.net/technosailor/ asynchronous-wordpress
  9. 9. Aaron Brazell • @technosailor • www.technosailor.com 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 (http://is10uphiring.com/) • Twitter: http://technosailor.com/twitter • Email: aaron.brazell@10up.com • Github: https://github.com/technosailor • WP.org Profile: https://profiles.wordpress.org/technosailor
  10. 10. Aaron Brazell • @technosailor • www.technosailor.com

×