When it comes to content management systems, WordPress is still the king. With over 31% of websites using WordPress as their CMS, it is essential for developers to know how to build on top of the popular backend. Previously the intricate, yet tangled, web of HTML and PHP that WordPress is known for, could be a bit clumsy and difficult to build on. This is especially true for front-end developers that are not familiar with PHP. But in that darkness there is now light and good news for front-end developers everywhere. WordPress 4.7 changed everything.
WordPress 4.7 was the first version to include a built in REST API. To keep it simple, think of a REST API as a way for developers to interact with website data using easy to read objects, called JSON files. The best part is that almost any programming language is capable of being used in this manner, as long as it can ask for data and interpret responses from the database. This allows any developer to create different user dashboards, alter plugins to be more responsive, and to build custom and very powerful applications on top of the WordPress CMS.
Recently, we decided to give the REST API a little test run. We built a single-page application using Facebook’s popular Reactjs framework as the front-end and WordPress as the backend. Although a bit tricky to setup at first, it allowed us to route data directly into the page without reloading the browser (an http request). Why is this significant? A complex answer can be condensed down to one word, speed!
On a ‘normal’ WordPress powered site, when you click on a post or link, a request is sent to the server to retrieve some information and load it onto the page. These requests take time, they can fail, and if you happen to be mobile and not in a good service area, you should probably put your phone down, go make a sandwich, then come back later. The development of a single- page application eliminates these issues. Once the page loads, all of the posts can be accessed without having to reproduce everything that is on the page. In the case of React, it pays attention to everything on the page and only changes what is necessary. Your content is loaded quickly, seamlessly, and all with the click of a mouse or touch of your finger.
This is just one small example of how using the WordPress REST API can be advantageous for your website, especially if you have users who tend to be mobile, which is probably most of them (just look around you when stopped at a traffic light!). If you feel that a customized single-page application would be a great addition to your site, please give us a shout. We’d love to explore that avenue with you and maximize all of the untapped potential that is waiting to be unleashed!
If you it so much, why don't you share it?