G2CROWD NAMES PANTHEON #1 IN WEBOPS See why real customers prefer our platform Learn More

Using JavaScript Beyond the Browser

This is a companion blog post to the conference talk I gave at the JavaScript for WordPress conference, online on July 12th, 2019. If you missed the talk or want to bookmark the recap and links, read on.

JavaScript Has Taken Over The World

As someone primarily working on web projects, I see JavaScript permeating all aspects of web development. For example, WordPress 5.0 introduced a new, JavaScript-based content editing experience, introducing the concept of blocks and replacing the decade-old single WYSIWYG text area.

If we look beyond just web development, however, we can see JavaScript taking over lots of other areas, as well. Octoverse, GitHub’s yearly analysis recap, has used JavaScript as its top language for the last 5+ years.

JavaScript still has the most contributors in public and private repositories, organizations of all sizes, and every region of the world.

Octoverse 2018 report, Github

I really got hooked on web development with PHP. If we look at Google Trends comparing PHP to JavaScript for a 5 year range, though, it’s clear that JavaScript is far more popular worldwide.

 

Putting Your JavaScript Skill To Use

This got me wondering where else, besides web development, can I use my JavaScript skills? It turns out the possibilities are almost endless. Let's look at a few examples.

Node.js and NPM

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine that allows JavaScript to be used server-side, not just client side. NPM is a software registry for Node.js packages. If you also work in web development, you probably interact with it on a weekly basis, as well.

So, still thinking about JavaScript outside web development, I looked over at the Roku stick in my living room and wondered if JavaScript can run there too? A quick NPM search lead me to the roku-client package, which allows you to control a Roku device by writing JavaScript.

Next, I wondered if command line applications can also be written in JavaScript. After all, I've written them in PHP before. Another NPM search lead me to the commander package, which allows you to use JavaScript to write command line applications.

Combine these two and you can use your JavaScript knowledge to write a command-line tool to control your Roku from the Terminal on your computer.

React Native

While the previous example is fun, no more reaching for the remote, it isn't super practical. You wouldn't bill a client for creating something like this. 

Mobile apps, though, are very much in demand and pair nicely with web development work you are already doing. React Native allows you to write native mobile applications with JavaScript. And if you've been doing web development you may even have React experience, making the barrier to entry very low—at least compared to learning another programming language, like Swift, just for mobile app development.

Serverless JavaScript Function

There is a serverless movement happening, where you can write JavaScript functions and not worry about their execution. There are many services that enable this, such as Google Cloud Functions, AWS Lambda, Azure Functions, and CloudFlare Workers.

I looked into Google Cloud Functions, since I am already familiar with the GCP service (Pantheon runs on Google Cloud). They have a tutorial on setting up a Slack Bot with Google Cloud Functions that is a great example of using JavaScript outside the browser.

If you want to explore serverless further, check out The Serverless Framework. It helps you build web, mobile, and Internet of Things applications with serverless architecture. I would encourage you to explore the IoT and see what fun things you can do with your JavaScript skills! If you're not sure where to get started, my co-worker, Steve Persch, did a talk on "Connecting your Development Workflow to The Internet of Things" that is a good place to start.

Google Apps Script

Did you know you can use JavaScript to control Google Suite applications with Google Apps Script?

You write code in JavaScript and have access to built-in libraries for favorite G Suite applications like Gmail, Calendar, Drive, and more.

- Overview of Google Apps Script

They have an example showing how to send emails from spreadsheet data. This gets me thinking about automating client reporting…

Automate Your QA Process

There are lots of automated test frameworks that use JavaScript. While not as far away from web development as controlling your Roku player, these tools can help you improve your workflow.

I did an entire workshop at WordCamp Europe on using visual regression testing to automate your QA process. I created an example Node.js app for the workshop using JavaScript.

After I run WordPress updates (core, plugins, and themes) on a site’s staging environment, I use the app to do a pixel-to-pixel visual check to make sure nothing has changed. This is something I used to do manually, which was very time consuming, and I still ended up missing things occasionally.

Making use of my JavaScript skills beyond the browser has allowed me to improve my QA process, reducing the time I spend while also mitigating the risk of deploying a bug.

JavaScript is Everywhere

It really is everywhere, which means the skills you've developed to help make websites are very transferable to a lot of other applications. Hopefully, this gets you thinking of ways you can use JavaScript beyond the browser. If you find something cool to do with JavaScript let me know in the comments or on Twitter.

Topics Development, Website Technology

Let’s get in touch

855-927-9387