Developer takes his own approach to replacing PHP with JavaScript inside WordPress, different from Automattic

Feb 8, 2016 20:40 GMT  ·  By

A new project called WordExpress, or WordPress Express, aims to replace the blogging platform's PHP codebase with one powered by JavaScript technologies like Node.js, Express, React, Relay, and Sequelize.

Started around two months ago, the project is the work of Ramsay Lanier, Senior Interactive Developer for nclud, a creative digital agency in Washington, DC.

As you may be aware, or not, Mr. Lanier's idea isn't entirely original, since Automattic, the parent company behind WordPress.com and the WordPress open source project, had already started a similar project at the end of November 2015. Automattic's project is called Calypso and is available on GitHub.

WordExpress takes a different approach as compared to Calypso

Despite the general idea, the two don't share that much code, with Calypso using WordPress' newly released REST API whereas WordExpress is leveraging a much simpler approach.

"There are a lot of reasons I started this project," Mr. Lanier told Softpedia. "I really really love developing user interfaces using React - developing websites at a component level is just easier to maintain. With WordExpress I'm leveraging CSS Modules so I have locally scoped CSS, which makes maintaining a website or application much much easier."

And this is not the only thing that's easier. "I also wanted to use GraphQL as a replacement for a REST API," Mr. Lanier continued. "With GraphQL, the client determines the data it needs and there is only one round-trip to the server, whereas with the [WP] REST API, you will probably need to hit multiple endpoints to get everything you need server side and then rely on the client to parse that data."

GraphQL is faster and leads to a better user experience.

WordExpress is 100% functional right now but only covers 20-30% of Mr. Lanier's desired features.

"The biggest features I'm working on right now is getting server-side rendering to work for SEO purposes," he explained, referring to the fact that WordExpress will generate and display content only to human users but will not do the same thing for search engine crawlers. This problem is very well known in the JavaScript community and affects most websites that don't use solutions like Prerender. "Right now, with GraphQL and Relay, all the data is determined client side and rendered on the fly," Mr. Lanier also added.

"Next, I'm trying to get all the built-in shortcodes to work, like [embed], etc. Right now, only [caption] works," he admitted, also pointing us to WordExpress' roadmap on GitHub.

If everything goes according to plan, in the best-case scenario, developers will have a fully working WordPress version that can run on Node.js servers and uses React for its user interface. Effectively, Mr. Lanier is trying to replace the underlying PHP & MySQL code with JavaScript and GraphQL, and also leverage Sequelize to interact with the old MySQL database via JS code.

Mr. Lanier's approach to using GraphQL, React, and Relay instead of the WP REST API looks much smoother and quicker, and surely deserves another look.

"It's an open source project, and there have been a [few] pull-requests submitted on GitHub - however, I'm the sole maintain of the project currently. I'd love involvement from WordPress core developers," Mr. Lanier told Softpedia. "This project started because I wanted a better development experience at work. Hopefully, as the project matures we can actually use it in production."