简体   繁体   中英

ASP.Net MVC slow JS load

I have a partial view within my application that uses a custom js control. The control effectively turns a listbox into a checked drop down list. That works perfectly. The quite lengthy code that deals with the rich interactivity for this (not the actual control creation) is in a seperate js file, referenced by the partial view.

When the partial view loads, there is a noticable visual delay where the listbox renders into the dropdownlist. You initially see the listbox, and then the dropdownlist.

However, if I include the JS code in script tags within the view then there is no delay. When the page loads, the control is fully rendered.

The JS file does not contain the logic for creating the control, just my manipulation code.

Anybody know why there would be such a delay using the same code, but with the difference being caused whether I am referencing a JS file or embedding the code direct into the view?

Thanks.

How many items are in the dropdown?

There is a known issue in IE8 with rendering long lists, it can be seriously slow!

Is the script in the external file wrapped with $(document).ready(...) or similar which would cause it to wait for all other elements to be rendered before executing?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM