Large number of HTML elements, Is there is any way to load the page faster?
Large number of HTML elements, Is there is any way to load the page faster?
I have a load page contains large number of html elements such as >150 forms and each forms having same name of elements but with different form names. E.g kindly please take a look over the attached html code. Since the requirement in such that I need to show all the 150 forms on one load. Also I try to use the yahoo YUI tab component, one tab contains 15 forms and the current screen is full already. I face a problem of very slow loading during initial load. Also I use ajax for server callings. So that I don’t have to redraw every time I post something to the server. It works fine. Am looking a solution for initial load delay. Kindly please give me some tips over on this, how to overcome on this issue.
Don't know why you need that many forms and all those inputs. Looks like a user interface problem more than anything else. Even with all that, it shouldn't take that long to load but I don't see the complete form either.
I would say, quit using tables for layout and that would speed things up but not as much as someone rethinking all that input. And that's not bringing up all the invalid markup either.
I notice you also repeat the same styling elements over and over. It's time to use CSS as a way of minimizing the formatting. Give it a look and see what you think. It can greatly speed up your loading time.
I'm with mikemacx, look at getting rid of the TABLE layout and instead use the CSS box model. In addition, one of the more important things you can do is to remove all the inline stuff (styles and JavaScript / event handlers) and push them to out to external files, encapsulating everything into functions, especially any repeated code. Any DOM code can and should be loaded at the very bottom of your document body, just prior to your closing tag (linked-in stylesheets should remain in the document head - use the LINK tag to pull in CSS instead of @import). CSS and JS can be compressed.
There is a really good article on the Yahoo! Developer site titled "best practices for speeding up your website". I've put some of those into action and made big improvements in page loads.
OK, you should definitely move your JS and CSS into external files. While I’m not at all sure what your page is about it seems like the forms do have their purpose so there’s not much optimization in terms of form markup. You should, however, scrap the tables and use more semantic HTML because except of the stats table at the bottom that’s not what tables are meant for.
Also if all the forms have the same markup and just a different name you couls use a PHP loop to generate the same HTML over and over again and just have the name as variable. This wouldn’t make less code for the browser but it might be easier for you to maintain since you only have to change one time in order to change all forms.
A few suggestions for cleaner code:
Use a proper doctype. Yours is incomplete and will throw IE into quirks mode. Also for IE the doctype must be on the very first line, no white space, character, or empty line should be before it. I strongly recommend HTML or XHTML strict.
Write all HTML lowercase.
Always wrap the attribute values with quotes like <select name="selectName">
The name attribute is deprecated for all elements (this includes the form element) except form controls. So you should replace the form name attributes with ID attributes. JS can pick them up like forms[‘form1'].