About image previews using Base64 on Chrome's performance problem solving method

Source: Internet
Author: User

In the development of the background to upload pictures of the function of using Base64 preview pictures, resulting in a large number of images caused by Chrome crashes, the code is as follows

                var New Image ();                 var New FileReader ();                 function (e) {                    = e.target.result;                };                Render.readasdataurl (file);

I guess is in the number of pictures too much and the picture is too large, the browser in the resolution of the Base64 file when the consumption of too many resources caused the crash, so the replacement picture preview way as follows:

                var New Image ();                 var New FileReader ();                 function (e) {                    varnew  Blob ([E.target.result]);                     = (URL | | webkiturl). Createobjecturl (BLOB);                };                Render.readasarraybuffer (file);

No longer use Base64, change to read the file binary, and then generate the resource link through Createobjecturl, which eliminates the base64 parsing process.

There are better ways to welcome a shot of bricks.

About image previews using Base64 on Chrome's performance problem solving method

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.