Skip to content

Instantly share code, notes, and snippets.

@21paradox
Created January 9, 2016 08:46
Show Gist options
  • Save 21paradox/a4ace6b52e1fef112b06 to your computer and use it in GitHub Desktop.
Save 21paradox/a4ace6b52e1fef112b06 to your computer and use it in GitHub Desktop.
render very large text in html page
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')
@21paradox
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment