Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #8362

Re: David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!feeder1-1.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <2724045.nNXnhXx0nj@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Wed, 16 Nov 2011 01:11:20 +0100
User-Agent KNode/4.4.11
Content-Transfer-Encoding 8Bit
Subject Re: David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML
Newsgroups comp.lang.javascript
References <b8aaaf65-2095-4145-8992-651aae0e9a69@p9g2000vbb.googlegroups.com> <j9ulej$141$1@news.albasani.net>
Followup-To comp.lang.javascript
MIME-Version 1.0
Lines 45
NNTP-Posting-Date 16 Nov 2011 01:11:20 CET
NNTP-Posting-Host 7d6854da.newsspool3.arcor-online.net
X-Trace DXC=M04L;QW5S\4T2Rfi6<W9f5McF=Q^Z^V384Fo<]lROoR18kF<OcfhCO;1Na@Z_S6Ve<DZm8W4\YJN<;?f@h5gMfb<BIlHSWN<J<?]6UNUkaj^d4
X-Complaints-To usenet-abuse@arcor.de
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:8362

Followups directed to: comp.lang.javascript

Show key headers only | View raw


Andreas Bergmaier wrote:

> David Mark schrieb:
>> Despite there being no standard behind the innerHTML property and the
>> somewhat awkward feel of dealing with serialized DOM structures, I
>> virtually always choose the string over the (XML) document object.
>> It's much simpler, faster, requires less code, less function calls
>> and, having debuted in IE 4, has enough successful history behind it
>> to be trusted.
> 
> Why is that faster?

Possibility: An assignment to `innerHTML' would trigger once a markup parser 
written entirely in the host environment's native programming language, such 
as C++, thereby probably being executed as machine code.  Whereas with 
several DOM method calls each would trigger the native implementation, 
switching to and back from native code in the process.  The stack operations 
involved in the latter, and the fact that the ECMAScript implementation 
would be single-threaded, could contribute to its being slower than the 
former.

> Only because the native html parser is faster than the javascript
> interpreter?

There is no "javascript", and you have a common misconception of how code 
written in an ECMAScript implementation is being executed by a Web browser.

> I could understand the use of innerHTML when it's for large static
> elements delivered as plain text per ajax - where the server can
> serialize the structure into HTML.

What you are writing may read sophisticated and even meaningful to the 
uninitiated, but it actually makes no sense at all.  I strongly suggest you 
familiarize yourself with the workings of Web server and browser – and 
perhaps English – before making further (English-language) statements on 
this topic.  For example, the Web *server* does not (need to) serialize 
anything if you use XHR to request HTML markup in the response message.


PointedEars
-- 
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML David Mark <dmark.cinsoft@gmail.com> - 2011-11-15 11:47 -0800
  Re: David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML Andreas Bergmaier <andber93@web.de> - 2011-11-15 22:26 +0100
    Re: David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML Gregor Kofler <usenet@gregorkofler.com> - 2011-11-15 22:57 +0100
    Re: David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML "J.R." <groups_jr-1@yahoo.com.br> - 2011-11-15 21:16 -0200
    Re: David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-16 01:11 +0100
      Re: David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML Andreas Bergmaier <andber93@web.de> - 2011-11-16 02:29 +0100
  Re: David Mark's Javascript Daily - Volume #3 - Tip #6 - How to Get and Set HTML Dr J R Stockton <reply1146@merlyn.demon.co.uk> - 2011-11-16 18:51 +0000

csiph-web