2582[jslint] Re: Suggestion for whitespace exception when building an HTML string
- Aug 24, 2011I've avoided putting the spacing in the string itself since it wouldn't get minified out. As for the concatenation cost, remember that I use YUI Compressor to minify the script which uses constant folding to combine literal strings during the minification step. That means that code that's written like this:
var myHtml = '<div>' + '</div>';
Gets converted to this when minified:
Storing the HTML in the DOM of course has performance implications and is also not practical in my real-world code; while the sample code I provided in my original post consists of all literal strings, in reality it's a combination of literal strings and variables. I used literal strings in my example for simplicity's sake.
- << Previous post in topic Next post in topic >>