Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Introducing JavaScript Where Does JavaScript Go?

Eppu Vahtola
Eppu Vahtola
8,531 Points

Just JavaScript in .js-file?

Hi,

In the "Where does JavaScript go" video Dave says that .js-files can contain only JavaScript and no other languages, however in the previous lesson we used js to print out a h1 html-element on the page? So we can include html in js-files, at least some elements?

2 Answers

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,242 Points

Hi, Eppu. When you are including HTML this way, it's really just strings that you are writing, which will be printed to the DOM, and thus interpreted by browsers as HTML.

Eppu Vahtola
Eppu Vahtola
8,531 Points

Hi Ryan. Thanks for your answer. I think I understand how this works, and apparently this will be explained more in-depth in future lessons.