Does reusing symbols improve SVG performance?

前端 未结 3 952
挽巷
挽巷 2020-12-05 18:11

Assuming a relatively modern, SVG-supporting desktop browser and an SVG consisting of hundreds of similar, simple nodes:

  1. The document could be set up as many i
3条回答
  •  一个人的身影
    2020-12-05 18:55

    I would advise you to not nest elements deeply. That is known to cause slowdowns in most browsers, see here and here.

    In the general case though it should be fast, at least as long as the template itself isn't changed much (since if you do then each of the instances need to be updated too, and each of them can differ from the rest due to CSS inheritance).

    Between and there isn't that big of a difference on a functional level, they both allow you to define a coordinate system (via the 'viewBox' attribute). A element doesn't let you do that. Note that elements are invisible unless referenced by a , whereas and are both visible per default. However, in most cases it's advisable to make the template be a child of a element.

提交回复
热议问题