In my JS Unit Testing presentation today for WPSessions (slides for the talk are available here), I showed a WordPress plugin I’ve written which is designed to improve the keyboard image navigation experience within the Twenty Fourteen theme. In that theme it’s possible to use the left and right arrow keys while browsing images to navigate to the previous or next image, but doing so triggers a full page refresh each time.
Since I needed to write some code anyway in order to demonstrate the use of QUnit with a WordPress plugin, I went ahead and wrote a small plugin that will replace the default Twenty Fourteen image navigation script with one that fetches the requested image via jQuery’s
.load method, injecting it directly into the page. If you’re using Twenty Fourteen on your own sites, check out the plugin on Github— and if not, feel free to check it out anyway just for the QUnit examples!
As always, if you notice any issues with the code (or have questions about how or why I’m doing things a certain way), feel free to leave a comment or issue on the repository and I’ll answer as soon as possible.
I am honored to be a part of this month’s excellent lineup, and I hope you will join me, Alison Barret and John Bloch online this coming Saturday!
Click on the banner above to sign up—tickets are just $25. (As with WordCamps, the recorded talks will be released for free a few months after the event.)
With a passing JSHint run we’ll be one step closer to having the front-end tooling infrastructure we deserve. It’s an exciting time to be involved in the project, and I’m grateful to Andrew Nacin, Tom McFarlin and everyone else who’s been supporting and encouraging our efforts.