Nov 7, 2010Most web developers know the importance of optimizing images for faster page loading times, but it’s also a very cumbersome, time consuming and boring process. Then when you are done, the customer or designer gives you new images to use and you can start the process over and over and over again. The result is that we spend a lot of time optimizing images and also forget to do it from time to time.
That’s why I’ve been experimenting with a way to automate the process of optimizing images for use on web pages. This has resulted in a Visual Studio 2010 extension to do just that.
The extension
The idea with automating the optimization is that the images must have the same quality in color and fidelity as before they were optimized. That is done with proven algorithms, and when an image has been optimized, it cannot be further optimized by the same algorithm. Nothing happens if you run the optimization multiple times on the same image – it will only be optimized the first time.
If you run the optimization on an image that has already been optimized using other tools, you might still be able to optimize further, but often nothing will happen - the image will not be touched when it has been analyzed and no optimization is found possible.
In this beta of the Image Optimizer extension, only JPEG and PNG files are supported, but that should hopefully cover ~90% of images in modern websites.
When you right-click a folder in the Solution Explorer in Visual Studio, you now have a new menu item called “Optimize images”.
When clicking the menu item, the image optimization starts. It looks for all images in the clicked folder and all its subfolders. You can also select multiple folders before right-clicking. As the images are processed, the result of the optimization is printed to the Output Window in Visual Studio.
The extension uses OptiPNG for optimizing PNG files and jpegoptim for optimizing JPEG files. I will go into more details about how it works in the coming weeks when the extension is more polished and open sourced.
Download
Please try it out and give me any feedback that will help improve it.
Download the extension in the Visual Studio Gallery
Apr 13, 2010I’ve used Google’s Page Speed plug-in for Firebug a lot since it was released last year. Even though it’s not as good as Yahoo’s YSlow plug-in, it’s still very usable for some scenarios YSlow doesn’t support – my favorite being the analysis of unused CSS and selector optimizations. It also has a feature that will tell you how much your web page will gain by minifying the HTML.
Not only does it analyze the difference but it can also generate an optimized version of your HTML. It removes unnecessary whitespace which in most cases are pretty harmless. But, it does more than that. It actually strips out attribute quotes from the HTML elements as well as remove the closing </body> and </html> tags. This renders the entire page invalid according to any WC3 (X)HTML standards. Even though it is a good idea to minify your HTML, this feature of the Page Speed plug-in makes it completely useless to me. Unless you’re Google, Twitter or Facebook, this feature is just strange.
Mar 15, 2010At the Mix10 conference, the Windows Phone 7 teams had some very big announcements – a lot of it had been kept secret and first revealed to the public now. There is however still some details they keep secret. Some of these secrets are the user agents of Internet Explorer for Windows Phone 7, which they simply wouldn’t give us. After playing with Windows Phone 7 we managed to secure a copy of the user agent string. The user agent for IE on Windows Phone 7 running on the Asus Galaxy device is:Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) Asus;Galaxy6Notice that it identifies the browser as IE7 and the operating system as Windows Phone OS 7. The IE team told us that the browser in Windows Phone 7 is a mobile version of IE7 with certain features ported from IE8. So it doesn’t use the full Trident 4 layout engine that IE8 uses, but instead Trident version 3.1 with a few extra capabilities.
The user agent was retrieved from server logs, so it is the actual user agent from the actual browser.
Nov 29, 2009The conclusion of my grand plan of 2009 saying I have to visit 12 different countries by the end of the year.
[More]
Jan 7, 2009Mads Kristensen won the Microsoft MVP award in ASP.NET
[More]
Aug 28, 2008I'm going to Florida for 14 days. See you on the other side.
[More]
Jul 11, 2008How and why I got started as a software developer
[More]
Mar 2, 2008Tech talk at Microsoft about BlogEngine.NET
[More]
Feb 26, 2008As you might have noticed, this blog has been displaying a beautiful yellow-screen-of-death for the last three weeks. It began only a few days since I went on vacation to Brazil. The thing was that I didn’t realize that the site was down until about 10 days into my trip, because I don’t like checking e-mails or even touch a computer while I’m on vacation.
Now I’m back home and have investigated what happened to the site. Of course, it was my own fault as these types of things always are. It turns out I exceeded my server disk space. I was aware of this, but somehow forgot about it even though I’ve been warned a few times.
Anyway, the blog is now working again and I’m sorry for any inconvenience it might have caused.
Jan 31, 2008Going to Brazil for a month
[More]