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.

Development Tools Introduction to Front End Performance Optimization Combine and Minify Assets Create a Sprite Map

Peter Campbell
Peter Campbell
18,085 Points

Why paste SVG code at the top of the body?

In the video, Nick pastes the SVG code at the top of the body. Is it closer to optimal perceived performance if the SVG files are pasted in just before they are used? My understanding is that in this case the SVG icons are in the footer and the browser would need to parse the SVG code before rendering the more important elements of the page.

1 Answer

You may be using it in several places around a page like on the contact page, so would you put it above the contact box or footer? The safe bet and best practice would be at the top of the document. Its still going to be much faster than several http requests and ideally you would want visual assets loaded early on.

To be honest the files are so small for little icons like this so you probably wouldn't even notice. I personally would link it for the sake of one small http request to keep my html clean.