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

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

Damien Watson
Damien Watson
27,419 Points

SVG Sprite Map added in body of page vs include?

In Nicks video of creating a Sprite Map with SVG, he adds each svgs element path data into the page. Is there a way to do this nicely through an include?

It makes sense to use an external file as it gets cached / one source of truth, but I can't find any good examples.

So... inline vs include anyone?

2 Answers

amourief
amourief
5,469 Points

I too would like an answer on this one. The second obvious advantage would be that you through an include the code for <svg> lives in a central place. The way that the video is demonstrating this is that it gets inserted into each page which means if there is a change it would have to be updated on several pages.

Would appreciate any thoughts on this.

Thanks in advance.

I have the same question, what is the difference between use a Sprite Map and using <use> vs add the SVG code directly in the DOM.