If you are into WordPress or JavaScript, or even both, you might have heard the news already. WordPress is (i.e., the core committers as well as several contributors and users are) evaluating JavaScript frameworks for adoption. This post is an interview with Wes Bos about exactly that topic.

Who Is This Wes Bos?

At the end of last year, I had a straightforward, easy-to-understand and even partly visual answer to the question who Wes Bos is.

Unfortunately, this isnā€™t up to date anymore, as there are stickers missing. And kombucha. And Syntax. And… Well, that guy just has too much free time. šŸ˜€

Wes Bos

Anyway, Wes Bos is a full stack web developer and designer from Hamilton, Canada. You might know him from one of his awesome, high-quality video courses, for example, ES6 for Everyone, React For Beginners, or, his latest one, Learn Node. If not, you really should check them out.

Wes is a lead instructor at HackerYou and Ladies Learning Code, and a regular conference speaker. He tweets a lot and writes in his WordPress-powered blog.

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.

Recent WordPress JavaScript chats as well as related discussions are mostly about React vs. Vue. Was this to be expected? Is there any framework missing?

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.

Update: With the latest news about Facebook relicensing React under MIT, licensing issues are ghosts of the past.
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

  1. Donā€™t create a WordPress-specific JavaScript framework, but pick something popular that will be around for a while.
  2. For something like WordPress, a dedicated state manager helps. A lot. And Redux seems to be a really solid option.
  3. 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.

One response to “Interview with Wes Bos about WordPress, JavaScript and React”

Leave a Reply

Your email address will not be published. Required fields are marked *