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

Joel Rivera
Joel Rivera
29,401 Points

Combining Scripts

Since each script tag requires an extra http request is it possible or worth combing script tags into one file so that there is only one request?

If so what would be the proper way to do it and can the file then be properly minified without losing functionality?

What happens if some files use strict mode and others don't?

1 Answer

Jon Wood
Jon Wood
9,884 Points

True, it'll cause an extra HTTP request, but keep in mind that after the initial request the files will be cached unless it expires or the file changes.

You could combine them all into one script file, but that reduces maintainability.