Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Header Include with JQuery

Can anyone help? I was trying to create an Inc folder with a header.php file; however when I use the file, the jquery stuff stops working? I think it's because page 1 links to one type of jquery slider and page 2 links to another type of jquery sliders and I have different css files for different things. What a mess! ;)

Here's the question: Do i just make an exhaustive list of all the jquery links and css files add it to the header.php file OR can i simply not use header.php includes if I have multiple pages with different jquery elements and css elements? So maybe keep the header.php for the simply pages and just a la carte the other pages.

1 Answer

Kevin Korte
Kevin Korte
28,109 Points

If you go your second route, than everytime you'll need to update the menu, or some other common header, item, you'll have to make that change on every file, yuck.

How many CSS and JS files do you have? Each on of those is a server request, and therefor a hit to performance. You'd be better off turning all of your CSS files into one or two larger ones. And than think about moving the JS files to the footer.