jquery - Is building big portions of page in javascript bad? -


on existing project working on, noticed many of developers building big portions of pages javascript. example:

$( targetdiv ).append("<div>"); $( targetdiv ).append("   <div class='info'>");       $( targetdiv ).append("        <div id='modes'>"); $( targetdiv ).append("          <table cellspacing='0'>"); $( targetdiv ).append("            <tbody>"); // more... 

i understand using javascript build certain elements on page. content dynamic , know when page first loads (ajax stuff).

however, of code (not shown) not dynamic , build same way every time. no 'if' statements or loops

is there reason why 1 build large parts of pages using javascript vs having html part of html doc? think 1 want minimize javascript html generation because more confusing , harder write. also, javascript html generation has hurt performance (does it?)

i "newer" javascript dev maybe missing something. want "newer" maybe don't "it"

thanks

that quite possible the horrible way have ever seen kitten getting killed. now, that's not kitten killed: each line kills thousands of kittens. , puppies.

don't this. it's wrong. it's bad. it's horrible. it's terrible. it's hell. it's good.

on more serious note...

  1. the code doesn't work intended. see comments on question.
  2. the html content, javascript behavior. you're mixing both absolutely no compelling reason.
  3. every time call dom, have time go grab coffee. you're calling append many times seeing hurts eyes.

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -