Interview with Wes Bos about WordPress, JavaScript and React

Written by Thorsten Frommen

Thorsten is a certified PHP engineer, web development professional and tester. He has been working on the web since 2000, and with (and on) WordPress since 2005. Thorsten is a Senior WordPress Engineer at Human Made.

Why This Interview?

One of the goals of these WordPress JavaScript chats is to make future versions of WordPress ship with a mature JavaScript framework so anyone interested in that can just make use of it. Of course, any new JavaScript-based or -powered core features will be built using the new framework, and eventually, WordPress’s JavaScript codebase will be refactored bit by bit. Right now, the only two frameworks (left) in the broader discussion are React and Vue.

Several weeks ago, Evan You, creator of Vue, stepped in and responded to a few questions and comments by either WordPress core committers or other participants in the discussions. While this sure helped clarify quite a few things, it, of course, also pushed Vue as an option.

Just to make that very clear: I do not have anything against Vue at all. I only heard good things, but I never used it myself so far. However, I thought that React, as second party in this battle, should get the same as Vue: someone knowledgeable who can provide meaningful insight into using the framework in and for WordPress.

So I asked Wes if he was interested in doing this interview. Why? Of all the JavaScript professionals, teachers and influencers I know, Wes not only knows React like the back of his hand, he also has advanced WordPress knowledge. Unlike Evan Young, however, Wes is not involved in the development of any of the systems. Therefore, Wes was the optimal candidate for such an interview. That’s why I’m still thrilled he did this. (And anything with/about Wes Bos just sells well, of course. 😀 )

Questions and Answers

Now, let’s get to the interview then.

Before we get right into JavaScript, let’s briefly talk about WordPress. When did you first use it, what did you do with it since, and when (and for what) did you use it the last time?

Wes: I first used it in pretty early days, probably WordPress 1, probably eight, ten years ago. I initially got into it, and I was a big fan of that. Back then, the big plugin that got released was this thing called Flutter. It allowed you to have custom fields, and that was huge for us. But since we’ve all changed through a couple different plugins. I was big in the Pods scene for a while, now I’m into the Advanced Custom Fields scene.

When did I last use it? Probably about two weeks ago. My own site is on it, my wife’s site is on it, I have a couple client websites on it that I still maintain, couple other things… Tons and tons of different installs on WordPress.

Wes: I don’t know. I think that React and Vue are sort of the hot ones right now. I think they’re both very good choices. Obviously, there’s other frameworks that are out there. Obviously, Angular is the big one. Marko from eBay seems to be a really nice one as well. There’s all kinds of other frameworks that could be, but I think going for the most popular one is a great idea, just because that’s going to give people the best option in being able to create things for it.

You know React inside out, no questions asked. Do you also have any experience with Vue?

Wes: Not really. I played with it a few times here or there. From my very limited impressions, it seems really easy to get up and started, which reminds me of Angular 1 days. It’s kind of like you try it, and then: oh, this is nice.

I think React has a lot of stuff that you need to keep in your head, like binding and all these weird gotchas, whereas Vue sort of just works, which is really really nice.

When and why did you choose React? Have you ever wanted to actively turn away from it? Do you see this coming?

Wes: I was initially an Angular dev, during Angular 1 days. And then Angular announced Angular 2 like way ahead of time, and they said it’s gonna be totally different. So there was this two-year period where I was kinda like, well, what’s the point of putting any time into Angular 1 if it’s all going to totally change. And then Angular 2 was so far away that it’s not I could just sit on my hands and wait for it.

At that time, React was becoming popular, I gave it a shot, and I really liked it. I really liked how it worked, I really liked how simple it was to build stuff, I really liked how it made me a better JavaScript developer… So, yeah. Big fan of it.

Turning away from it? No, I don’t think so. I’ve always liked it. I mean, there’s lots of things that I don’t like about it, but you sort of just learn to work with those. That’s just part of buying into a framework.

Some people mentioned creating a WordPress-specifc JavaScript framework from scratch. What do you think about that? While something like this is doable, should it really be done?

Wes: I don’t think that’s a good idea. I think you should pick something that is already out there, and something that will be around for a while. Otherwise you have to learn yet another WordPress framework. I think that sometimes developers pigeonhole themselves into being a WordPress developer, rather than just a web developer and WordPress is a tool—that’s always been my approach to it, and WordPress is just one of the many tools that I use. So, it’s better to sort of get away from thinking in terms of WordPress, and get more into thinking in terms of a web developer, where WordPress can help you. So any WordPress-specific stuff—I’m not always a huge fan of. Besides from things like themes and plugins, which obviously need to be done on top of the WordPress core.

Does React fit as JavaScript framework for WordPress core? What about themes or plugins?

Wes: I think so. I think that there’s gonna be some challenges in terms of sharing data, just because, in PHP and in WordPress, it’s so easy to just pull in data wherever you want. And now if you’re trying to make components that need to fit into a larger JavaScript, we’re gonna need to look at something like Redux or Apollo, which will make it really simple to just inject the WordPress data into a component at any level, and be able to call these custom functions. Otherwise it’s gonna be a bit hard for people to transition from thinking in terms of WordPress over to React.

There are quite a few concerns about React being hard(er) to learn. With your React For Beginners course, you claim people can learn React in an afternoon or two. How does this fit together? Do you think React is hard to learn? What do your students say?

Wes: I think React is hard to learn because people don’t necessarily know all that much about JavaScript. And then you compound that with having to learn JSX, or having to learn a whole bunch of new ES6 stuff that you might not necessarily have used before. Then there’s the whole compile stuff… I think there’s a lot of like moving targets in React, whereas with WordPress you drop a theme in and you’re up and running. So someone moving over from WordPress to React is gonna be in for a bit of surprise, because I know that there are still quite a few WordPress developers who simply just FTP in and start live-editing a file, whereas React is like the total opposite of that.

So, I think that is hard, but once you get over that initial hurdle—you could do that by taking my course, or doing a couple tutorials—you can get over that fairly quickly. And I think that it’s good for you, because it overall makes you a better developer. And, of course, I think that’s why my course is doing so well, because React is a little bit hard to get up and started with, so that’s exactly why you need to put in a little bit of time, or do something like my course.

My students say that it’s great. They say that it was hard to initially learn, because there’s so many moving parts, there’s so many tutorials out there, but if you can have a singular resource you can just focus in on, then that would really help.

React is licensed by Facebook, and there is this additional grant of patent rights that has been subject to the most controverse discussions. Did you ever run into any trouble because of this? Or did you ever have a bad feeling when (thinking about) using React? Should WordPress?

Wes: No. But that’s because I’m not anyone who is building products that is worried about this. A lot of people asked my this question, and I don’t really know. The answer seems to be: use Preact, which uses the exact same API, but is not licensed under Facebook. So that’s sort of an easy one to do, and that’s been tested with the whole Google Java thing where they have used the same Java API, but recreated it themselves. So, I don’t know. I really wouldn’t sweat it all that much, but I’m not a lawyer at the end of the day.

Let’s assume there really was some danger involved when using React, the framework. Fortunately, there are other options out there that follow the same (or fairly similar) principles that React is built on. For example, Preact. What are your thoughts on this?

Wes: Yes, I think Preact is great. Especially from performance and licensing standpoint. I think it’s really cool that React has built this standard API, and then everybody can build different frameworks using the exact same API.

Something (that should be) very important is state management, both in the WordPress admin and in the front end. Do you agree? What does React itself, but also its ecosystem offer in this regard?

Wes: Yeah, you definitely need a state manager, especially when you’re going to be getting heavy. It’s easy just to use state if it’s all your application. But when you get into using third-party components, or being able to integrate into somebody else’s React, a state manager is gonna help you quite a bit in this case. And at this point, Redux seems to be a really really solid option, and I’ve recently been looking at Apollo, which uses Redux under the hood, to do this as well with GraphQL. So, definitely, that needs to be taken into account when looking at WordPress.

One thing in WordPress that is not JavaScript itself, but fairly related to it is the WordPress REST API. If WordPress was shipping with React, would plugin authors gain anything when it comes to working with the WordPress REST API?

Wes: I think that if you were building a plugin these days—and especially if WordPress adopts either Vue or React—then it would be a great idea to build it entirely on top the REST API, rather than having to deal with page refreshes and whatnot. You could build some pretty slick plugins, and I know a lot authors are already doing this.

Finally, which of the two frameworks do you think will win, and ship with future WordPress releases? Why?

Wes: I don’t know. I wish that I could predict the future, but—if you pardon the pun—I’m more of a React-ionary guy. I think that there’s people really taking time to consider all the ins and outs of all the different frameworks, and I rather them do that than me, who hasn’t spent a whole lot of time reading into it, just sort of slinging opinions here and there.

I think whatever they choose to go with—whether it’s React or Vue—will be a really good choice. And I think people will be pretty happy with it over the years as it starts to develop.

Thanks a lot for your time and knowledge, Wes. Really very much appreciated.

Wes: You’re welcome.

Takeaways

Don’t create a WordPress-specific JavaScript framework, but pick something popular that will be around for a while.

For something like WordPress, a dedicated state manager helps. A lot. And Redux seems to be a really solid option.

No matter if it will be React or Vue, it will be a really good choice, and people will be pretty happy with it.

What Do You Think?

If you have anything to say about either the whole WordPress JavaScript framework discussion, or something specific in this interview, please, let me know in the comments below. Thanks so much in advance.