Input[type=file] The solution to slow and lag problems when open

Source: Internet
Author: User
The following small series for everyone to bring a piece of the following small series for everyone to bring a quick solution input[type=file] Open slow, lag problem. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.

Why is it very slow to open a local folder when the input tag type is file-uploaded with a property accpet= "image/*"in the label?

The test found that safari, Firefox, and Chrome (which opera doesn't know why) are not stuck in the Mac.

In Windows, Firefox doesn't lag, only chrome.

So I decided to try to get rid of Accpet first ...

Sure enough, there is no problem of stalling.

Then this package in try accpet= "image/jpg" really also not Kaka!!

It seems that the problem is "image/*."

But the original intention of writing Accpet is to want to filter out all the pictures _ (: З"∠) _

So in order to achieve this requirement, and to improve the user experience, you can only take the enumeration

The modified code


<input type = "File" accpet= "Image/gif,image/png,image/jpeg,image/jpg,image/bmp"/>

Try again, it's all settled!

It turns out that Chrome's safebrowsing feature checks the file when it's uploaded or saved.

If the network is connected to Google faster, there is no problem.

But if the connection is slow, or if you simply kneel down, the safebrowsing will let Chrome hang up for a while until the file check is over or timed out

Using accept= "Image/png, Image/jpeg, image/gif" can solve this problem because these MIME types are in the safebrowsing Whitelist and do not need to be checked.

But if you use something like accept= "image/*" , it's not going to work, it could become Kaka.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.