Is there a way to create out of DOM elements in Web Worker?

后端 未结 9 881
一个人的身影
一个人的身影 2020-11-30 02:58

Context: I have a web application that processes and shows huge log files. They\'re usually only about 100k lines long, but it can be up to 4 million lines

9条回答
  •  执念已碎
    2020-11-30 03:29

    I don't see any reason why you can't construct html strings using web-workers. But I also don't think there would be much of a performance boost.

    This isn't related to Web-Workers, but it relates to the problem you're trying to solve. Here are some thing that might help speed things up:

    1. Use DocumentFragments. Add elements to them as the data comes in, and add the fragments to the DOM at an interval (like once a second). This way you don't have to touch the DOM (and incur a redraw) every time a line of text is loaded.

    2. Do loading in the background, and only parse the lines as the user hits the bottom of the scroll area.

提交回复
热议问题