How to learn JavaScript as a WordPress developer

Like many WordPress developers, I started learning JavaScript before I really even knew what JavaScript was. By learning JavaScript I mean that I Googled how to make dynamic changes to the CSS on my page, discovered that jQuery was the option, and later found out that jQuery was a JavaScript library, and so on.

WordPress is a safe space from which we can explore the different technologies surrounding it to improve our sites and create more dynamic experiences for our users. This includes JavaScript.

The discussion around JavaScript-driven interfaces isn’t new, though. In 2012, Founder of Ghost, John O’Nolan, who was at the time leading the WordPress user interface team, suggested a more simple, blogger-focused WordPress rather than a CMS. After becoming frustrated with WordPress’s more complex approach, O’Nolan left the WordPress project and founded Ghost. Ghost eschews PHP for Node.js on the server side while WordPress has maintained the traditional database layer we call WordPress.

Calypso is a good example of the type of JavaScript Single-Page Applications that sites will need moving forward as they attempt to meet the specific needs of their users. I doubt there will be a universal API. I do, however, think that as WordPress developers we need to learn how to better build these types of applications. This is what excited me most about Mullenweg’s challenge to learn JavaScript, deeply.

I recently sat down with fellow Torque contributor Roy Sivan on The WP Crowd to discuss how to learn JavaScript as a WordPress developer.

You can hear our whole conversation by watching the video, but I want to share some thoughts from the discussion. Also, Carl Alexander, a writer that provides useful content to help improve PHP development skills, shared some thoughts on JavaScript with us after that the recording that were really useful.

What framework should you learn?

Based on the way people talk about the WordPress REST API, it often seems like it is absolutely essential to learn a JavaScript MVC framework. While it may be helpful, it also limits perspective on learning the REST API or mastering JavaScript.

There are a lot of frameworks to choose from. Determining which one to learn is a difficult decision. I have no interest in debating this. They are all just tools. Choose the one you are comfortable with and move on.

Learning a JavaScript MVC framework is a quick way to start building something. But it’s not going to give you a deep understanding of the language. In fact, it may actually prevent you from learning the language deeply.

Most WordPress developers are not used to the MVC pattern since WordPress doesn’t use it. And until you are exposed to it, it’s not easy to grasp. Learning that, plus JavaScript itself is a tall order. Personally, the first few times I looked at Angular it was way too confusing for me. Then I learned Symfony, which didn’t require any new PHP knowledge, but it did require me to grok the MVC pattern. Once I started to understand it, Angular came much easier to me.

Angular, jQuery and Backbone are not useful when it comes to learning JavaScript. None of them will help you learn how object-oriented programming works in JavaScript. On the other hand, Roy and I have been working on a single page web application as a plugin admin screen for our automated A/B testing plugin.

On the other hand, Roy and I have been working on a single page web application as a plugin admin screen for our automated A/B testing plugin Ingot. It would have been insane to write the whole thing in vanilla JavaScript when a few hundred lines of Angular could make it work.

Learning a framework provides tremendous value. It helps you get things done, become more familiar with the language, and gain a better understanding of how that type of coding works. Roy has a great series on building web applications with Angular and the WordPress REST API, which is a useful resource for those looking to learn these skills.

  •  
  •  
  •  
  •  
  •  
  •  
  •