Home  >  Article  >  Web Front-end  >  java-web Jquery initialization delay problem_html/css_WEB-ITnose

java-web Jquery initialization delay problem_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:22:241039browse

This post was last edited by MUTOUYIHAO on 2013-07-10 12:36:20

jQuery performance optimization jsp java web

Now the project is developed using jsp, and there are some elements in the page It uses a bunch of defined js and css to initialize dom elements for style control. Currently used elements such as menu sometimes have a delay of about 1 second without style modification when the page is loaded, but sometimes there is no delay. , I guess it’s due to caching?
The page implementation steps are as follows:
0. Reference css style
1. Define dom element
2. Reference js (jquery) at the end of the page to initialize dom element style

Finally, it is js initialization Before the execution is completed, the browser renders the dom element, and later the js initialization is completed and the page becomes normal.

There are many elements in the page, so for subpages loaded using jsp’s include directive, sometimes there will be an ‘original’ display about 1s after the page is loaded.

I wonder what you guys have to say about this kind of large page loading execution optimization problem

Reply to the discussion (solution)

Personal opinion
Apply the style of the fixed dom element directly to the dom element
or split the script file that controls the style and reference the split script file to the split based node element
or add the outermost div Hide it first, and then control its display in the referenced script file

Make a div to cover it to indicate loading

After jquery has processed the official dom, hide this div

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn