How would you select svg or canvas for your site?

Technology CommunityCategory: HTML5How would you select svg or canvas for your site?
VietMX Staff asked 3 years ago

SVG is a language for describing 2D graphics in XML. Canvas draws 2D graphics, on the fly (with a JavaScript). The differences between SVG and Canvas would be helpful in selecting the right one.

Canvas

  • Resolution dependent
  • No support for event handlers
  • Poor text rendering capabilities
  • You can save the resulting image as .png or .jpg
  • Well suited for graphic-intensive games

SVG

  • Resolution independent
  • Support for event handlers
  • Best suited for applications with large rendering areas (Google Maps)
  • Slow rendering if complex (anything that uses the DOM a lot will be slow)
  • Not suited for game application

Conclusion:

  • SVG is better for applications and apps with few items
  • Canvas is better for thousands of objects and careful manipulation, but a lot more code (or a library) is needed to get it off the ground.