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 trialJoe Elliot
5,330 PointsInteresting fault when my HTML script tags were in the wrong order. Why is this?
So I'm using VS Code editor as I code along with this class. My push method kept returning "Patron is undefined". I eventually figured out it's because in my HTML, the the <script src> tag to my "Library" File was ABOVE the <script src> tag to my Book/Patron files. Moving the library <script> tag to the bottom solved this.
So, it seems the order you list your HTML links to your JS files is important. I was previously unaware of this. Is there a simple logic to this order? Is it something a developer knows in advance?
1 Answer
Rohald van Merode
Treehouse StaffHi Joe Elliot,
That's correct! The HTML file is being read from top to bottom so the order of importing your files does matter. If one piece of code depends on another file to run you'll want to make sure to add those script tags in the right order 🙂
Joe Elliot
5,330 PointsJoe Elliot
5,330 PointsThanks Ronald, I guess it makes sense that the Books and Patrons have to be populated in this example, before a library can be created for them.
Thanks again!