Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple html vs Javascript generated html?

In my web application I would like to complately avoid html and use only javascript to create web-page's dom tree.

What is faster writing web content in the traditional way in html <div>Some text</div> or using javascript dom render, like this: div.appendChild(document.createTextNode("Some text"));?

like image 552
Rizo Avatar asked Jun 03 '10 19:06

Rizo


People also ask

Should I create HTML with JavaScript?

Use Javascript to inject HTML only if the site is meant to work without an Internet connection, or a similar case.

Which is better HTML or JavaScript?

JavaScript simply adds dynamic content to websites to make them look good. HTML work on the look of the website without the interactive effects and all. HTML pages are static which means the content cannot be changed. It adds interactivity to web pages to make them look good.

Can JavaScript generate HTML?

Javascript has some helpful methods that allow us create HTML elements. This is important in cases where we do not want to hard-code the markup but rather generate them dynamically when certain events happen in the browser.

What is the advantages of JavaScript over HTML?

JavaScript AdvantagesSpeed − JavaScript is a "interpreted" language, it cuts down on the time needed for compilation in other programming languages like Java. Another client-side script is JavaScript, which accelerates programme execution by eliminating the wait time for server connections.


1 Answers

Stick with the traditional HTML. It's not only faster than doing everything with javascript, it's much more maintainable.

Unless there is a compelling reason otherwise, stick with the straight up HTML and use javascript for the more interactive pieces of your app.

like image 171
Nathan Avatar answered Sep 26 '22 06:09

Nathan