473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

straight html or dom generated html objects faster?

Im wondering if generating html objects such as tabels and rows in
javascript is faster than typing the html directly? Seems when you do
it in javascript you have to download alot of code and would slow down
displaying the page. while if you just type the html, it requires less
bandwidth and display faster?

is parsing html to display in browser slower than doing it through dom
to display the same html objects on the page?

Jan 2 '06 #1
1 1827

anagai wrote:
Im wondering if generating html objects such as tabels and rows in
javascript is faster than typing the html directly? Seems when you do
it in javascript you have to download alot of code and would slow down
displaying the page. while if you just type the html, it requires less
bandwidth and display faster?
"download a lot of code" is a pretty wrong idea. The code is there. If
the browser creates a line of a table from <tr>..</tr>, it calls the
very same createElement() that you would call to do so from Javascript.

The answer is ambigious though, because while calling DOM functions
from JS to create elements is faster because of skipping the whole
XML/SGML parsing, it is at the same time slower because of launching
userspace javascript program which takes up CPU space. Whether the
speedup or slowdown is stronger depends on lots of factors.

Obviously sending <script>for(var
i=1;i<10000;i++){document.appendChild(createNode(' br'))}</script> will
take less bandwidth than sending 10000 BR tags. Which will take shorter
is a different matter though,
is parsing html to display in browser slower than doing it through dom
to display the same html objects on the page?


The objects to be displayed must pass both steps. First to be parsed as
HTML, then the resulting tree rendered as DOM. Likely the former is
slower, but for static HTML both are needed. If you generate elements
with a script, you skip HTML parsing, but then there's whole script
parsing, compilation, checking, execution and it takes time too.
Generally createElement will be faster than document.write() or
..innerHTML (and more reliable too), but most likely
document.getElementById('popup').style.display="bl ock";; after having
created 'popup' with static HTML earlier will be faster than
document.appendChild(popup);

Jan 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: catchanu | last post by:
Hi friends, In my project, I am generating an asp file that collects the data by querying database and puts it into xml document. XSL is applied to XML and this report in generated as HTML by...
72
by: Mel | last post by:
Are we going backwards ? (please excuse my spelling...) In my opinion an absolute YES ! Take a look at what we are doing ! we create TAGS, things like <H1> etc. and although there are tools...
0
by: vanGogh | last post by:
I have generated classes based on an Xml schema file (xsd) using the XSD.exe tool. My goal is to: - write an application that can parse XML documents - fill objects (based on the generated...
0
by: Viorel | last post by:
Working as a beginner with data objects in Visual Studio 2003 and C#, I use the "Generate Dataset" command in order to generate automatically the dataset objects based on data adapters. Generated...
7
by: Alan Silver | last post by:
Hello, I am a complete and utter newbie at ASP.NET, so please forgive any stupid questions ;-) I am just trying to get my head around the whole web forms business, but have run into a...
10
by: George | last post by:
Hi, I have a report which shows all records from database into the browser. The final HTML comes out about 5 Meg. It takes 1 minute 5 seconds for transfer to show up when i hit the page with IE...
26
by: webrod | last post by:
Hi, I have some php pages with a lot of HTML code. I am looking for a HTML validator tool (like TIDY). TIDY is not good enough with PHP tags (it removes a lot of php code). Do you have any...
3
by: NullQwerty | last post by:
Hey folks, I've got a DataGrid that has gotten a little out of control and really slow because of its complexity (bunch of Template Columns too). For performance reasons, I'm looking to change...
0
by: rupinderbatra | last post by:
Hello Everyone, I am trying to build a website where on click of a button, I am fetching some data from a web service (in code-behind) and displaying it using a repeater control. The repeater...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.