Home > Article > Web Front-end > Use javascript to solve image scaling and optimization code_image special effects
A client contacted me and told me that the website he had just built was not displaying properly. I immediately became nervous. This was the first project I had completed independently, so I quickly opened his website and looked at it. I didn’t see anything abnormal. Come. I asked him again why it was abnormal, and he said it was different from the effect when handing over the project. Haha, if it was abnormal during the handover, the project would definitely not be handed over. I might as well ask him to take a screenshot. Sure enough, it was abnormal. It was a picture he had just uploaded that opened the window displaying the content. Looking at the code, it is clear that max-width has been written, so why does this situation still occur? Suddenly I found that the browser in the picture he sent looked unpleasant, like the ancient and sacred IE6! After confirmation, it was indeed it, and it was it again! I was really negligent and handed over the work without testing it under IE6.
Speaking of IE6, those of us who are doing front-end work are really annoyed and helpless because many attributes are not supported. But many users are still using it, and we cannot ignore it. For the sake of compatibility, I had to ask my colleagues for advice, and then used js scaling to display images for IE6 and made some detailed optimizations.
Although today’s client website is relatively small and does not have high requirements for website performance, I consider that these things may be used in the future. Optimization is a long-term learning process. I checked some articles and said If you use the onload method of the img tag to call a function to modify the size, it will have a greater impact on performance. In addition, using -expression behavior seems not advisable (will continue to verify it later), so in the end it is triggered when the page is loaded.