Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7940229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:19:42+00:00 2026-06-03T23:19:42+00:00

SVGs inserted into a document using javascript look like gibberish because they have symbols

  • 0

SVGs inserted into a document using javascript look like gibberish because they have symbols with conflicting IDs inside them. For instance, these two different svg files

http://filebin.ca/1LMtJr5zc2x/svg1.svg

http://filebin.ca/1LN9F5ZPIbH/svg2.svg

When inserted into a document with javascript*, one of them looks wrong (in my case the a’s turned into x’s). If you open the SVG files with a text editor you’ll see they both have a line like this

<symbol overflow="visible" id="glyph0-0">

So I’m guessing the browser sees the second svg reference “glyph0-0” and uses the one defined by the first svg. Is there some way to tell the browser “symbols defined inside an <svg> only matter there”? Like restricting the scope of symbols.

<img> tags which point to those two files don’t have this problem. However I’m not using that solution because then the server would have to keep a bunch of files around and keep track of when they can be thrown away. With my current solution the browser has the SVGs in memory and they’re gone when the window closes.

*with XMLHttpRequest, I fetch a dynamically-generated SVG file, clone the root <svg> tag and append it to the document.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:19:44+00:00Added an answer on June 3, 2026 at 11:19 pm

    IDs are always global to a document, and non-unique IDs are considered invalid according to the HTML spec. If you require two symbols to have the same id, try using “class” instead of “id”. You could also do some regex pre-processing of the SVG string to adjust the IDs so they’re unique.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble with manipulating SVGs through javascript. I'd like to increase the
I'm importing SVGs with imagick using this syntax $graphic = new Imagick($this->img); The problem
I'm using the batik transcoder for svgs , and every time I convert an
Under CF9, I'm converting SVGs to PNGs using the Batik (1.7) transcoder. The SVGs
I'd like to use SVGs as scalable background images (e.g. a rounded rectangular as
I'd like to use a makefile to convert a set of svgs to pngs.
We are using Inkscape basically as a means to create SVGs. Once done, we
I'm struggling with namespaces in my *X*HTML application. I have to download SVGs with
I would like to use SVGs in menus and buttons around a Qt-4.7 application.
I'm trying to use document.createElement('circle') to work with svgs but Chrome creates a end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.