Is appending the html faster than pasting it multiple times?

Alin

Say that I have a <div class="statistics"></div> that I need placed in 5 different places in a single HTML page. That statistics div has a 6 row long list.

My question is this..

Is it faster to use:

<div class="statistics"></div>

and then use jquery like this:

$( ".statistics" ).append( $(<ul><li>content</li><li>content</li><li>content</li><li>content</li><li>content</li><li>content</li></ul>'));

...rather than copy/paste the code in those 5 different places ?

EasyBB

If you want faster and efficient with use of jQuery we can use it with native js

$('.statistics').each(function(i) {
    var newDOM = document.createElement('ul');
    newDOM.innerHTML = '<li>content</li><li>content</li><li>content</li><li>content</li><li>content</li><li>content</li>';

    this[i].appendChild(newDOM);
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Concatenating strings faster than appending to lists

From Dev

Concatenating strings faster than appending to lists

From Dev

Appending an Element multiple times in DOMDocument

From Dev

Appending multiple elements to html

From Java

Declaring multiple arrays with 64 elements 1000 times faster than declaring array of 65 elements

From Dev

Why is Udcast is many times faster than Netcat?

From Dev

Why @autoreleasepool is 6 times faster than NSAutoreleasePool?

From Dev

Why is appending to an element not yet in the DOM faster than using a javascript Fragment?

From Dev

Why is a list comprehension so much faster than appending to a list?

From Dev

Why is returning a list faster than appending to a return variable?

From Dev

Why is this function faster and why are multiple enumerations of it faster than the first?

From Dev

Why is this function faster and why are multiple enumerations of it faster than the first?

From Dev

Why is Matlab 11 times faster than C++

From Dev

Java sequential implementation is 4 times faster than parallel implementation

From Dev

OpenCL sample program executes 10 times faster on CPU than on GPU

From Dev

Why is multiplied many times faster than taking the square root?

From Dev

Why is the second execution of this combinator 10 times faster than the first?

From Dev

MSSQL: Why is this index 10 times faster than the other one?

From Dev

Why is VC++ matrix times vector faster with openMP than async?

From Dev

How to stop an alert message appending multiple times when using .each()

From Dev

Global Header and Footer for Printing in C# (rather than copying and pasting same info several times)

From Dev

Appending multiple options to html in d3

From Dev

Why is detaching and appending more efficient than changing html directly?

From Dev

Why is detaching and appending more efficient than changing html directly?

From Java

Is < faster than <=?

From Dev

copying few values in a row and pasting it multiple times in the same row in excel using VBA

From Dev

Can a multithread program with `k` threads run more than `k` times faster than its sequential version?

From Dev

Making a faster wavelet transform/Appending data faster

From Dev

Copy and pasting multiple cells

Related Related

  1. 1

    Concatenating strings faster than appending to lists

  2. 2

    Concatenating strings faster than appending to lists

  3. 3

    Appending an Element multiple times in DOMDocument

  4. 4

    Appending multiple elements to html

  5. 5

    Declaring multiple arrays with 64 elements 1000 times faster than declaring array of 65 elements

  6. 6

    Why is Udcast is many times faster than Netcat?

  7. 7

    Why @autoreleasepool is 6 times faster than NSAutoreleasePool?

  8. 8

    Why is appending to an element not yet in the DOM faster than using a javascript Fragment?

  9. 9

    Why is a list comprehension so much faster than appending to a list?

  10. 10

    Why is returning a list faster than appending to a return variable?

  11. 11

    Why is this function faster and why are multiple enumerations of it faster than the first?

  12. 12

    Why is this function faster and why are multiple enumerations of it faster than the first?

  13. 13

    Why is Matlab 11 times faster than C++

  14. 14

    Java sequential implementation is 4 times faster than parallel implementation

  15. 15

    OpenCL sample program executes 10 times faster on CPU than on GPU

  16. 16

    Why is multiplied many times faster than taking the square root?

  17. 17

    Why is the second execution of this combinator 10 times faster than the first?

  18. 18

    MSSQL: Why is this index 10 times faster than the other one?

  19. 19

    Why is VC++ matrix times vector faster with openMP than async?

  20. 20

    How to stop an alert message appending multiple times when using .each()

  21. 21

    Global Header and Footer for Printing in C# (rather than copying and pasting same info several times)

  22. 22

    Appending multiple options to html in d3

  23. 23

    Why is detaching and appending more efficient than changing html directly?

  24. 24

    Why is detaching and appending more efficient than changing html directly?

  25. 25

    Is < faster than <=?

  26. 26

    copying few values in a row and pasting it multiple times in the same row in excel using VBA

  27. 27

    Can a multithread program with `k` threads run more than `k` times faster than its sequential version?

  28. 28

    Making a faster wavelet transform/Appending data faster

  29. 29

    Copy and pasting multiple cells

HotTag

Archive