What is the fastest way to create a select tag with 5000 options in IE6?

In usability: what is the fastest way to create a select tag with 5'000 option elements in IE6 from JavaScript?

0
source share
2 answers

Short test:

  • First, assemble the innerHTML stream and paste it into the document: around 300 ms
  • adding options to an existing select element with a new option (): about 25 seconds
+5
source

Adding parameters using the DOM methods will re-arrange / redraw the screen for each parameter, slowing it all down. Using innerHTML after building a string (in memory) to select is much faster (as Dr. Mall said). An alternative to both methods can be to create a documentFragment in memory, create the selected object in it, and finally add its contents to the existing DOM.

This is in addition to the question of how the user should process 5000 options of course (alas, the user is not programmed;)

+3
source

Source: https://habr.com/ru/post/1346532/


All Articles