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 trialSanjeev Veloo
4,713 PointsWhen using Ajax, does jQuery need to be in the header?
You know everyone's saying to place the jquery scripts in the footer, but what about when you are using Ajax? Is this the exeption when you need the jquery stuff to be in the header of your page?
2 Answers
stjarnan
Front End Web Development Techdegree Graduate 56,488 PointsNo, you should still use it after your content.
The reason for this is that you allow your content to load before the ajax request, preventing a situation where the user has to wait for a JavaScript file to load before getting to see any content.
Christopher Debove
Courses Plus Student 18,373 PointsHello,
Like Stjarnan said, all your scripts should be at the end of your HTML for better performance. Then your scripts which using jQuery (and potentially Ajax) should be added after the jQuery script.