开发者

Does 'un-filled' form inputs slow down a website?

开发者 https://www.devze.com 2022-12-15 18:00 出处:网络
I have a page which has a drop list inside a form. The drop list contains \'Categories\' of ads. Depending on 开发者_C百科the value chosen in the drop list, I use javascript to show/hide DIVS on the

I have a page which has a drop list inside a form. The drop list contains 'Categories' of ads.

Depending on 开发者_C百科the value chosen in the drop list, I use javascript to show/hide DIVS on the page, which all contain different form inputs for the user to fill in. All this still inside the form!

Now, when the user has filled in all form inputs inside the 'SHOWN DIV', and clicks 'SUBMIT', the other form inputs remain 'unfilled'.

My Q is, does these 'unfilled' inputs slow down things? Is it needed to make them (the form inputs) disabled instead of only not visible inside a hidden DIV?

BTW, the page is php based and the forms action is set to a php file.

Thanks


The bandwidth required to send all of the additional form markup to the user whether or not they are visible is really the only point your application would be slowing down any. When the user submits the form only the field data for the current form is sent, so all of the other unused fields are simply disregarded.

Unless your page contains a considerable amount of extra markup to include the additional form fields, you probably need not worry about including them in the rendered HTML.


I guess it depends on what you mean by slow down? If you mean the processing of the form data when its posted, then no, it doesn't. If you mean the rendering of the page in the browser, than the answer is "maybe".

Inputs hidden in divs are not actually drawn on the page until your code that shows them is executed. At that point they will draw themselves, and depending on the speed of the user's system or their browser's rendering engine, it can be slow or fast.

Generally, no, you don't have to worry about performance in this regard. You can hide them in divs with no ill results.


You don't need to make the other form's fields disabled, as they won't get submitted. Multiple forms don't slow things any more than other markup. Having 10 forms in a page is equally slow as similar amount of other content.

If performance is a concern to you, have you considered changing the contents of one div, instead of having one div for every option? This way you could reduce the amount of forms considerably. Not that it would matter much though – perhaps only to users on slow connections that have to download that extra content.


Firebug net panel or HttpWatch can tell you the size of the postdata sent with a request. It probably isn't a big performance hit, but comparing the size of the postdata with the hidden form fields commented out to the current size to see how many bytes are added.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号