A New Vue On JavaScript30 - Getting Started
Tags: anewvueonjs30, vue, javascript30, javascript
Published: 2018-08-03 03:59:27

---
title: A New Vue On JavaScript30 - Getting Started
published: true
tags: ANewVueOnJS30,Vue,JavaScript30,JavaScript
canonical_url: https://davefollett.io/2018/08/01/a-new-vue-on-javascript30-getting-started/
cover_image: https://davefollett.io/2018/08/01/a-new-vue-on-javascript30-getting-started/a-new-vue-on-js30.jpg
series: A New Vue On JavaScript30
---

A few months ago, I worked through the [JavaScript30](https://JavaScript30.com) video tutorial series created by Wes Bos ([@wesbos](https://twitter.com/wesbos)) as a way improve my [JavaScript](https://en.wikipedia.org/wiki/JavaScript) skills. While I didn’t keep up with his one a day recommendation, I did 2 a week, I really enjoyed it and learned a lot. Part of what drew me to JavaScript30 was that it is entirely written with vanilla JS - no frameworks, no libraries, and no compilers. But as I got into it, I was left wondering, what would it look like if [Vue](https://vuejs.org) were used? With this series I will explore the differences between the two approaches.

Don’t worry, I cleared writing about with this the author himself.

![Thanks Wes!](https://davefollett.io/2018/08/01/a-new-vue-on-javascript30-getting-started/wes-bos-ok.jpg)

Ok, lets get started with some setup that we can use as the base of all the projects. One of the things I really liked about Wes’s projects are that each one is just an HTML file.  With Vue being the progressive framework that it is, we can match that concept with just a few lines.

## Including Vue

```html
<head>
  <meta charset="UTF-8">
  <title>GETTING STARTED</title>
  <!-- Use Vue from a CDN -->
  <script src="https://unpkg.com/vue"></script>
</head>
```

As mentioned in the [Vue Docs](https://vuejs.org/v2/guide/installation.html#CDN), I'm including Vue using the [UNPKG CDN](https://unpkg.com).  This is a really easy way to include Vue but not have to setup a Vue project.

## Root DOM Element

```html
<div id="app">
  {{ message }}
</div>
```

This <code>&lt;div id="app"&gt;</code> element is what I have configured to be the root DOM element for the Vue instance to manage.  All the HTML for the projects will be added here with some embedded Vue directives.

## The Vue Instance

```javascript
  var app = new Vue({
    el: '#app',
    data: {
      message: "Hello World!"
    },
    computed: {
    },
    methods: {
    },
    mounted: function () {
    },
    watch: {
    }
  })
```

The Vue instance is where most of the JavaScript from Wes's series will end up.  I've stubbed in some of the common Vue features I will be using but I'll defer the explanations to the Vue docs:
* el - https://vuejs.org/v2/api/#el
* data - https://vuejs.org/v2/api/#data
* methods - https://vuejs.org/v2/api/#methods
* mounted - https://vuejs.org/v2/api/#mounted
* watch - https://vuejs.org/v2/api/#watch

## Putting It All Together

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>GETTING STARTED</title>
  <!-- Use Vue from a CDN -->
  <script src="https://unpkg.com/vue"></script>
</head>
<body>

<!-- Vue Root DOM Element -->
<div id="app">
  {{ message }}
</div>
  
<!-- Vue Instance Section -->
<script>
  var app = new Vue({
    el: '#app',
    data: {
      message: "Hello World!"
    },
    computed: {
    },
    methods: {
    },
    mounted: function () {
    },
    watch: {
    }
  })
</script>

<!-- CSS Section -->
<style>  
</style>

</body>
</html>
```

Under forty lines and we have a nice starting point for the rest of the projects.  Seeing the whole thing at once highlights the beauty of Vue.  And just like the original JavaScript30 projects, you can just open the HTML file from your computer in your browser, no web server needed. 

I hope you enjoyed this article, feel free to message me with any questions, comments, or _corrections_.  All code presented within this series is available in [my fork](https://github.com/davefollett/JavaScript30) of the official [JavaScript30 GitHub repository](https://github.com/wesbos/JavaScript30) which is located at:
* https://github.com/davefollett/JavaScript30

## Up Next

Next in the [A New Vue On JavaScript30](/t/anewvueonjs30) series is:

{% link /davefollett/a-new-vue-on-javascript30---01-javascript-drum-kit-1k7f %}


## Thanks Again
I'd like to thank Wes Bos again for creating and sharing such a fun and inspiring course.  In addition to [JavaScript30](https://JavaScript30.com), Wes Bos has a lot more content available on his website and hosts one of my favorite podcasts called [Syntax](https://syntax.fm) with Scott Tolinski ([@stolinski](https://twitter.com/stolinski)) from [Level Up Tutorials](https://www.leveluptutorials.com).