Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does createElementNS work?

Tags:

javascript

svg

I don't really understand how does createElementNS works. For example:

svg = "http://www.w3.org/2000/svg";
group = document.createElementNS(svg,"g");

Does this connect to the specified namespace and gets the definitions for the g element?

If so... if placed inside a for there will be some kind of request to the specified url?

Is there another way to create a g element? One that does not require online connection?

I don't think so because I don't see any requests going there but still... is a bit ambiguous.

The reason why I'm asking is that something is greatly slowing my script down and I don't know exactly what.

like image 643
zozo Avatar asked Feb 24 '12 10:02

zozo


People also ask

What does createElementNS do?

createElementNS() Creates an element with the specified namespace URI and qualified name. To create an element without specifying a namespace URI, use the createElement() method.

What is Namespaceuri?

The namespace URI is what allows us to identify uniquely the namespace. It is also called the namespace name. If you use an URL, you will take advantage of the uniqueness of domain names in the domain name system (DNS).


1 Answers

Does this connect to the specified namespace and gets the definitions for the g element?

No. You can't "connect" to a namespace. http://www.w3.org/2000/svg is a unique identifier for the namespace, but namespaces are not URLs. The software handing the DOM needs to understand SVG (and will have the namespace mapped internally to its understanding of it).

The URL http://www.w3.org/2000/svg is a document that tells readers where to find more information about SVG, but that is just the authors being helpful, there is no programatic significance of a document existing there.

like image 115
Quentin Avatar answered Sep 20 '22 15:09

Quentin