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
Santiago Herrera
9,547 PointsI have several pieces of Javascript and Jquery scripts in my index.html file, how do I merge them together?
Hello, how about I got to create a maybe a main.js file with bit pieces of codes that make different functions?
I have got something like this, looks kinda messy in my HTML, making my head too large
<!-- Aditional scripts -->
<script src="js/slidenavbar.js"></script>
<script src="js/blurnavbar.js"></script>
<script src="js/sidebar.js"></script>
<script src="js/hashes.js"></script>
<script type="text/javascript" src="js/smooth-scroll.min.js"></script>
<script type="text/javascript" src="js/smooth-scroll-config.js"></script>
<script src="js/initpopup.js"></script>
```
1 Answer
Ray Karyshyn
13,443 PointsI would simply copy and paste all my pages of code into one document called main.js.
However, there are some free sites that allow you to upload a folder of javascript code and compress them into a single file.
Here are some examples:
The reason you want to do this is not only because your head will fill up, but also your site will load faster in browsers.
Ray Karyshyn
13,443 PointsRay Karyshyn
13,443 PointsI would compile a script for bootstrap and a seperate script for jquery.
Santiago Herrera
9,547 PointsSantiago Herrera
9,547 PointsThank you! Hopefully all will still work. What about external scripts for example boostrap and jquery?