mixxorz / django-inline-svg

A simple SVG template tag for Django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Considering using groups and <use ...> ID references

ryanmcgrath opened this issue · comments

This project is awesome, but one thing you may want to consider is using <g> groups in a larger hidden SVG tag and then outputting <svg ...><use xlink:href="#id"></svg> where the SVG should go. As it stands right now it looks like you're outputting the full SVG each time, which ultimately increases the total size on the request. By using the groups you can just shove each SVG in once and go from there - this works for me in my personal projects, and I've not found any browser issues with it (someone can correct me if I'm wrong).

I'm not sure why but I don't see people do this too often, seems overlooked in terms of a good practice. Maybe a configurable option?

I think same-page referencing of SVG shapes does work on all current browsers (including IE), but external referencing ones do not. [1][2]

I think this is an interesting proposition! I think I'll take a gander. Thanks!