I’m making a project that includes a lot of elements creation and appending, after a little research i came up with that
$(newElement) and $(selector)
are slower than
.createElement(newElement) and .getElementBy
Since i’m doing a todo-list app which will include a lot of creation/appending/selection of this :
<div class="mainTaskWrapper clearfix">
<div class="mainMarker"></div>
<label for="task1">This is task1</label>
<div class="holder"></div>
<div class="subTrigger"></div>
<div class="checkButton"></div>
<div class="optTrigger"></div>
<div class="mainOptions">
<ul>
<li id="mainInfo">Details</li>
<li id="mainDivide">Divide</li>
<li id="mainEdit">Edit</li>
<li id="mainDelete">Delete</li>
</ul>
</div>
</div>
What would you advise me to use ? jQuery selection and creation way, or JavaScript one ?
When you say “a lot of creation/appending/selection”, what exactly do you mean?
Is it in the order of several per second, or just “a lot”? Since the code will run client-side, one per second won’t be that much of an issue.
jQuery would then be the ‘best’ choice, as maintainability is a large plus, and any code you write with jQuery will probably be a lot clearer.