Skip to content Skip to sidebar Skip to footer

How To Replace Content Of Javascript Syntax Highlighter?

I'm using a javascript syntax highlighter (http://alexgorbatchev.com/SyntaxHighlighter/). I think this one is very famous. in my js, I use ajax to get code samples and then initial

Solution 1:

Just empty the wrapper element, put the new content inside, and then run syntax highlighter on that new code.

There shouldn't be any memory issues. Afaik, Syntax Highlighter simply creates a DOM structure (a table with DIV's, etc.) based on your code block. When you remove that table from the DOM (for instance wrapper.innerHTML = '';), all those elements are garbage collected.

Post a Comment for "How To Replace Content Of Javascript Syntax Highlighter?"