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 trialAr33ss Leon
4,621 PointsDoes scripts order matter?
For example I have this in this order(like the video):
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.validate.bootstrap.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/bootstrap-datepicker.min.js"></script>
validation works well. But when I just switch the third script with the first, validation does not work well.
1 Answer
Steven Parker
231,271 PointsWhether the order matters will depend on what's in the script. If the script uses anything that is contained in a different script, the other script(s) must be loaded first.
For third-party code, the supplier's instructions should mention the necessary loading order. Package naming may also be a clue. In your example above, if you know that Bootstrap depends on jQuery, the order shown is intuitively the appropriate order with the possible exception of the the third and fourth items (which may be interchangeable, I didn't check the specs).
Ar33ss Leon
4,621 PointsAr33ss Leon
4,621 PointsThanks <3