L
L
lagudal2018-05-02 12:39:36
SVG
lagudal, 2018-05-02 12:39:36

Why does firefox detect an error in svg, but everything is ok in chrome?

Greetings, there is a need to display svg (dotted europe map) as a background - I display it in full code, thus:

background-color:#000000;
background-image: url('data:image/svg+xml,<svg version="1.1" id="europe-map" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="1920px" height="800px" viewBox="0 0 1920 800" enable-background="new 0 0 1920 800" xml:space="preserve"> <pattern x="413.7" y="810.8" width="2.125" height="2.125" patternUnits="userSpaceOnUse" id="SVGID_1_" viewBox="0 -2.125 2.125 2.125" overflow="visible"> <g> <polygon fill="none" points="0,0 2.125,0 2.125,-2.125 0,-2.125 "/> <g> <polygon fill="none" points="0,-2.125 2.125,-2.125 2.125,0 0,0 "/> <path fill="#5F5F5F" d="M0.495-1.063c0-0.313,0.254-0.565,0.567-0.565S1.63-1.375,1.63-1.063c0,0.313-0.254,0.567-0.567,0.567 S0.495-0.749,0.495-1.063z"/> </g> </g> </pattern> ..../></svg>');

(Full code here )
If you open the url under investigation in google chrome, then everything is fine, but in firefox, not everything is so good:
XML Parsing Error: unclosed token....
......
Line Number 1, Column 537:

well, it points to the allegedly unclosed path tag, which, as can be seen in the code, is very closed.
And at the same time, ff incorrectly displays this svg even as a picture -
this svg is a picture
In chrome, again, the picture is displayed normally.
The assumption is the following.
In order to minimize this svg, I use a simple pattern overlaid on a closed path. Otherwise, if you display each point - in fact a circle - the file size increases from 18-19 kb to 1 mb or more. Hence the assumption that ff does not know how or otherwise interacts with the pattern tag in the svg body.
Is there a correct solution to this problem, anyway, the main thing is to keep the size small?
It is desirable except as different backgrounds for different browsers, ie. I would not like to load and minimize also jpg, which, with noticeably worse quality, is noticeably larger in size?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-05-02
@webinar

Adobe Illustrator 15.1.0, SVG Export Plug-In

Guarantee of a heap of shit markup. So first you need to get rid of it, the easiest way is to use: https://jakearchibald.github.io/svgomg/
And you should specify the encoding:
background: url('data:image/svg+xml;utf8,<svg ...> ... </svg>');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question