Loading ...
Sorry, an error occurred while loading the content.

2582[jslint] Re: Suggestion for whitespace exception when building an HTML string

Expand Messages
  • paulcrowder1979
    Aug 24, 2011
      I'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:

      var a='<div></div>';

      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.
    • Show all 7 messages in this topic