Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
When working on a project in a text editor, it's common to put all of your JavaScript code into a file that's separate from your HTML file.
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
>> When working on a project in a text
editor, it's common to put all of your
0:04
JavaScript code into a separate file
that's separate from your HTML file.
0:08
Just like you would with CSS, for example.
0:11
So now I'm going to open my text editor,
Visual Studio Code.
0:14
So you use the script element to
add JavaScript to an HTML document.
0:17
You can place script tags almost
anywhere in an HTML file.
0:21
But most typically you'll find script tags
placed either in the head of the page or
0:25
within the body of the page just
before the closing body tag.
0:30
I'll place it in the body.
0:35
And I'll set the source to main.js,
0:39
which is a JavaScript file I created for
my project.
0:41
When you place your script near
the bottom of the page like this it
0:48
let's the browser load and display
the HTML before running the JavaScript.
0:51
Next, I'll teach you more features of
JavaScript you'll likely work with daily
0:56
as a developer.
0:59
Like functions, loops,
arrays, and objects.
1:00
There's a whole lot more to learn
about each of these topics.
1:03
But I'll get you started with the basics.
1:05
And later give you more information
about where to learn more and
1:07
practice what you've learned.
1:09
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up