Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List.js L419 #1

Closed
Incognito opened this issue Oct 20, 2011 · 4 comments
Closed

List.js L419 #1

Incognito opened this issue Oct 20, 2011 · 4 comments

Comments

@Incognito
Copy link

https://github.com/javve/list/blob/master/src/list.js#L419

You can speed it up using native DOM methods, rather than innerHTML. Presently you're demanding the DOM be interpreted as a string and causing the browser to do a lot of re-rendering work, innerHTML is bad for performance, but will assassinate performance when inside a loop.

I'd suggest using text nodes or DOM fragments:

https://developer.mozilla.org/En/DOM/DocumentFragment

You have the opportunity to improve speed where you get the values as well: https://github.com/javve/list/blob/master/src/list.js#L410

@javve
Copy link
Owner

javve commented Oct 20, 2011

Ah, good point! Thanks for the heads up. Will add it as soon as possible.

I'm trying to focus pretty much at performance, mainly to be able to handle really large list, so all tips are valuable!

@javve
Copy link
Owner

javve commented Nov 16, 2011

I've been thinking about this for I while and have come to the conclusion that even if innerHTML is less good for performance, it's still needed because the values could sometimes be html-content.

E.g. images.

@javve javve closed this as completed Nov 16, 2011
@Incognito
Copy link
Author

At the very least provide the option that detects of the argument is a string or an object, and in the case of the latter extend the function to accept a dom fragment and append the node in, that way you can fully support the entire dom, rather than limit users who can write dom-methods and those who don't understand the API to write strings. This way you haven't forced those who can write faster code into a corner, but you've allowed those who work with strings to do what they want.

@javve
Copy link
Owner

javve commented Nov 16, 2011

Hmm, maybe! Performance is important, but I do not want to put too much options into the script and there by make it more complicated to understand.

I will look in to the possibility of adding this function!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants