Performance issues when modifying HTML with jQuery


/ Published in: JavaScript
Save to your folder(s)

I just found this interesting comment in the jQuery Syntax Hiliting Plugin "Chili".
It seems, one should preferrably use innerHTML instead the core jQuery method...
(Just to clarify: I didn't do any benchmarking myself)


Copy this code and paste it in your HTML
  1. el.innerHTML = dish; //much faster than $el.html( dish );
  2. //tried also the function replaceHtml from http://blog.stevenlevithan.com/archives/faster-than-innerhtml
  3. //but it was not faster nor without sideffects (it was not possible to count spans into el)

URL: http://plugins.jquery.com/project/chili

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.