Created
January 9, 2016 08:46
-
-
Save 21paradox/a4ace6b52e1fef112b06 to your computer and use it in GitHub Desktop.
render very large text in html page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var el = document.body; // any parent html element | |
var iframe = document.createElement('iframe'); | |
el.appendChild(iframe); | |
var doc = (iframe.contentWindow.document || iframe.contentDocument); | |
(iframe.frameElement || iframe).style.cssText = "width: 100%; height: 100%; border:0"; | |
doc.open().write('<pre>'); | |
// start write large text to html | |
doc.write('...xxx') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is pretty useful when rendering very large text file in html page, also don't block the normal page rendering.
Page is still very fluent while text is more than 20k lines.
Also because you render the entire text in the page. You can do search as you like(instead of lazy rendering in virtural-dom and implement your own searching module).
Btw,while text is large enough(>20k lines). Rendering in virtural-dom can be pretty slow either.