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
Alex Flores
7,864 PointsCan there be too much SVG?
I'm drawing a background landscape in Illustrator that I was planning on saving as an SVG and having some animation. I was planning on having this SVG image being the entire background of my website. Now I'm wondering if this is too much SVG? Will this slow down my computer?
Am I better off to create a raster image of the non-moving parts and then just use the SVG for the moving parts. The SVG image is fairly complex (it's a cartoonish looking city with a few gradients).
I was hoping to get some of your thoughts!
Thanks!
3 Answers
Tim Knight
28,888 PointsAlex,
I would say that you'll likely be seeing better performance with using just your SVG graphic. First your download speed is going to perform better than a rasterized graphic since all you're sending across the wire are your vector points in the SVG markup. Next, your animation will use some browser resources, but you're going to need that regardless if you use your rasterized background. Personally I haven't really seen a huge performance hit with large SVG files. I'd say to watch your dev tools during animation debugging just to see how you're performance is... but likely it's going to be about optimizing your animation from any repaints then really the CPU cost of the browser rendering vector points.
Tim Knight
28,888 PointsAlex, yeah I would encourage you to keep it simple because depending on your animation you will have to move each point. You might consider looking at something like Snap.svg at http://snapsvg.io/ which is an API good for animating your SVGs. It will probably simplify your code a lot.
Sue Dough
35,800 PointsMake sure the SVG's are inline so you don't use extra http requests. Try to avoid adding base 64 images in the SVG if possible.
A background landscape could be overkill depending on how big/detailed it is. If you link to it that would be helpful.
Alex Flores
7,864 PointsThanks Sue, I recently came to that realization when Illustrator itself kept crashing on me due to the size....
Alex Flores
7,864 PointsAlex Flores
7,864 PointsThanks Tim! I have one more question, if you don't mind... I want to add brush strokes to a few of the characters in the SVG file. However, when I do that my Adobe advises me to rasterize the image, because there are too many paths. If I were to animate an object that has brush strokes on it, I would have to move each brushstroke via CSS, correct? From what you said, it sounds like this could work too - granted it would take a lot of time...
Alex Flores
7,864 PointsAlex Flores
7,864 PointsThanks Tim! I have one more question, if you don't mind... I want to add brush strokes to a few of the characters in the SVG file. However, when I do that my Adobe advises me to rasterize the image, because there are too many paths. If I were to animate an object that has brush strokes on it, I would have to move each brushstroke via CSS, correct? From what you said, it sounds like this could work too - granted it would take a lot of time...