Scott Hanselman

Useful Visual Studio Extension - Web Essentials from Mads Kristensen

November 08, 2011 Comment on this post [62] Posted in ASP.NET | Tools | VS2010
Sponsored By

Visual Studio 2010 is really extensible and that's allowed many folks on the team to try out new features for Web Development without having to rebuild Visual Studio itself. One of those "playground" extensions is called "Web Essentials" by Mads Kristensen. Mads handles HTML5 and CSS3 tools for our team. You might remember Mads from when we released the Web Standards Update a few months back.

Web Essentials is Mads' playground and it's pretty awesome. It's so awesome that I think you should check it out and then, *ahem*,  leave a comment on this post encouraging Mads and gentle urging his boss(es) to get these features into the next version of Visual Studio.

First, it adds a few nice touches to the CSS Editor in Visual Studio. As you can see below, it adds a little glyph next to each color that shows you the actual color.

A nice visual refresh to the Visual Studio CSS editor

If you hover over the colors, you'll get a preview with more details. You'll also get font previews on mouse hover.

Font Previews are fun

These are just nice little touches that make you smile. They also smooth little issues with my daily workflow. After having them, I miss them when they are gone.

There's also some more functional features, like embedding tiny images in your CSS files as base64. Sounds nuts, but if  your small icons are so small that the HTTP Headers are larger than the image itself this can be an easy way to remove an HTTP request.

Here I'm taking the tiny "Ajax Loader" PNG in my app and turning it into an inline image.

Embed Resource as base64

So those

Look at the tiny images as base64

It even has some evil little helpers help you use well-known CSS hacks to control visibility of rules. Like, if you hate yourself and use IE6. ;)

Enabling evil with IE6 hacks

You can minify just a selection of text if it makes you happy.

image

You can drag and drop images and automatically get a background-image CSS rule, which is a HUGE time saver. Oy. All this and a bunch more little subtle stuff.

The best feature and feature that should cause you to download it NOW is that you can do live CSS editing in Visual Studio with a real-time preview.

Fire up a CSS file and hit Ctrl-Alt-Enter. Then click Settings and hit "Live Update CSS." Bam. As you type it'll get updated in the browser. Love this.

image

Do you like these playgrounds? Do you want some or all of these features in Visual Studio? Sound off below.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
November 08, 2011 5:18
I remember when VS2010 was in beta, and one of the big demos was integrating a 'rich preview' of XmlDoc, inline in the code.
Whatever happened to that?
I have been waiting for an inline HTML editor that will display XmlDoc in the formatted form, and allows me to use some kind of rich editor (all inline) for adding the markup tags...

Im a big proponent of verbose xml documentation, but anything to motivate my team to do this would be a big help.

Is this available anywhere?
November 08, 2011 5:23
+1 for Base64 encoding of images in css
A little feature for a lot of value
November 08, 2011 5:30
@curchy,

It also works for embedding fonts using the @font-face directive
November 08, 2011 5:31
Definitely include this functionality. Would love to have these featuers built in.
November 08, 2011 5:42
I've always wondered what happened to Mads after blogengine. It felt like to me he dropped of tue face of the earth. Glad to see he is still making a dent in the world and doing good for our community.
November 08, 2011 5:48
Yes - this would be nice to see in Visual Studio. I have something like this with Telerik JustCode, but it would be nice if it was in the core Visual Studio (So I could dump Telerik :)).
November 08, 2011 7:21
Every single one of these features should be standard in Visual Studio! That is all. :)
November 08, 2011 7:21
Love these features... just wish they were available in my preferred editor, VS 11 :)
November 08, 2011 8:15
+1 for @font-face 64 byte embedding. Also, those little glyphs are a life saver.
November 08, 2011 9:57
A lot of these features are also,contained in Resharper from jetbrains. Nonetheless a valuable tool!
November 08, 2011 10:06
It sure seems like it's a 'no-brainer' to add this to VS. It gets a little closer to the convenient Silverlight way of designing, and it helps remove the most cumbersome part of modern web development--CSS. Si, Por Favor!
November 08, 2011 10:42
Love the extension but it seems to clash with others that I have installed-- I think it doesn't like Resharper?

That's the problem with VS extensions, you just don't know which ones don't play nice together, which ones slow you down a ton, etc..
November 08, 2011 12:06
Just installed it and already like it... definitely features that should be included in Visual Studio by default :)
November 08, 2011 12:25
Too bad it's not compatible yet with .less (and the Web Workbench extension)
November 08, 2011 12:49
This is good to hear. Will download the web essentials. I already have the web standards update. display the hex color value saves me enough to try out this add-on and I see a lot more good stuff! font-preview is for me personal less valueable, but also nice to have.
Embed resource as base 64 is awesome! saves me a lot of trouble and does decrease http requests! so thats better for the end user experience as well. same for minifying! nice to have that in visual studio!

ps. 'make visible for IE6 only' should have a nuke icon or demon or something. Skulls are less evil (because of pirates of the Caribbean)
November 08, 2011 12:53
Looks very useful. Only thing not so keen on is the promotion of the use of CSS hacks. These things should really be handled using conditional comments and seperate stylesheets for the various IE browsers as necessary.
November 08, 2011 13:47
So yeah, after playing with it for a little bit - immediately I want it to do more...

For example - unless I'm missing something, can you specify the browser engine that it uses to render the live preview?
November 08, 2011 14:13
Love the extension I think I'll get addicted to live preview and color preview...!
It should def be included in VS by default
November 08, 2011 14:24
Am I doing something wrong or Live Web Preview renders page using IE7 standards? If so, then it's not really a usable feature.
November 08, 2011 14:53
Excellent addition to the standard VS functionality.

These features should definitely be included "as standard" in Visual Studio, however, there should always be the ability to enable/disable each specific piece of functionality (via the Tools>Options menu).

Best of both worlds.

November 08, 2011 15:06
They're nice but not essential so if included by default on VS they should come disabled or easily disabled as a whole.

The best solution is to keep it as an optional Extension that we can choose to install from Tools>Extension Manager.

Please don't slow down the IDE performance (which directly affects productivity) with these kind of things, the IDE is already eavy enough.
November 08, 2011 15:58
Awesome
November 08, 2011 16:31
Man, that's why I love Visual Studio. Visual Studio is the first IDE of the world contrary to IE, which is the most damn browser ;).

Scott, thanks for introducing this great extension. I enjoyed it.
November 08, 2011 16:57
A live preview, ever more "liver" (like firebugs, where the preview reacts as you change the CSS) in long overdue.

The other things are nice, but not a big deal.
November 08, 2011 17:18
If anyone is doing VS Live conferences, I highly recommend checking out Mads' presentations. He covered this stuff (and more) at VS Live in Redmond 3 weeks back, and it was AWESOME. As a guy who's spent a lot of my time as a "front end" .NET developer, these new tools are very, very appreciated.
November 08, 2011 17:23
Mads,
Awesome extension! Thanks for sharing this with us!

Boss(es),
Please get these into the next verson of Visual Studio!

Scott,
Always enjoy your articles!
November 08, 2011 19:48
This looks pretty friggin' amazing, particularly the live editing. Nice work, Mads, downloading this now.
November 08, 2011 19:58
Most of these features are trivial novelty items, IMO. I'm not opposed to their inclusion, but I'd have concerns about performance. It's already annoying at times when you're opening a large code file and have to wait for the tools to catch up / parse the file. Cute features like this seem like they'd only add to that lag.

Personally, I'd like to see more built in tools that actually help you better organize CSS and such, like integrated support for LESS.
November 08, 2011 20:14
Great stuff, makes the job easier for me :)

I really hope they make the next version of Visual Studio!
November 08, 2011 20:33
Yes, I want these features in the next Visual Studio ! thanks, Bill
November 08, 2011 20:41
Downloading.....Installing....Not supported for any versions installed....

Curse you Express versions!

P.S. Make this one work for VS 2010 Express :)
November 08, 2011 21:02
Neato!
November 08, 2011 21:04
I use this quite often. Love it. Great work Mads!
November 08, 2011 21:36
+1 for Web Essentials.
Please include in the next version of Visual Studio
November 08, 2011 23:23
Interesting stuff. I have recently created a NuGet plugin which provides similar functionality as its preview feature, but use quite different way to do that. I used ajax long polling to refresh the css file or the whole page whenever a save action is detected.
November 08, 2011 23:25
@Mihhail Maslakov,

The issue with IE7 rendering mode is fixed and will be in the next update shortly
November 09, 2011 2:06
A big fan of Mads since early days of BlogEngine.

+1 for any feature he gets out of his playground to be in next release of VS
November 09, 2011 6:55
VS2010 and extensions,
how do I love thee?
let me count the ways..
November 09, 2011 7:39
@kipusoep,

Version 2.2 is compatible with .less files and the web workbench extension (except for a few things)
November 09, 2011 9:10
Just downloaded it awesome thanks
November 09, 2011 10:47
.LESS support would be awesome!

BTW .. Have followed Mads for years... his .net blogs were always simple, clever and useful!
November 09, 2011 11:00
>>> .less files and the web workbench

Yes Mindscapes's Web Workbench was a great tool - but some clashes with the fantastic "Chirpy" and the decision to turn the freeware version of Web Workbench into "Nagware" forced a de-install.

The case still stands: Native VS2011 support for LESS and/or SCSS(sass) would be FANTASTIC!


November 09, 2011 13:42
Why there is no comment/uncomment css line/s button to the menu in the VisualStudio css editor
November 09, 2011 19:08
Just awesome! It's the little things that add up to big things for a web dev on a daily basis!

Thanks Mads!!!!!
November 09, 2011 19:43
This is awesome! I hope it makes it into the next version of Visual Studio!
November 10, 2011 15:59
5! I'm using this tool for some time and updates with improvements comes reguraly. Good job!
November 11, 2011 12:59
This is brilliant! The color glyph alone is priceless. Would love to see this baked-in as standard.
November 11, 2011 17:34
Nice. This just blew up Visual Studio completely, it conflicts with something else (I don't recognize the names) and now I can't even open the menus.
November 11, 2011 17:36
Nevermind, it seems only the mouse was disabled, I was able to open the menus with the keyboard and managed to uninstall it. Everything works now. (Leaving this as a FYI in case anyone else has the same problem.)
November 11, 2011 19:34
This is something that should be baked into all versions (Express, Matrix, etc).
November 11, 2011 22:48
@Marcel,

That's terrible. Sorry about that.

Can you share with me what other extension you have installed so I can fix this conflict, please?

Thanks
November 12, 2011 21:10
The "embed resource as base64" feature never popped up for me no matter what I've tried. Please help.
November 13, 2011 2:55
@Andrew,

There was a bug in the WAP vs. Website project types. Update the extension to version 2.4 and it should work
November 13, 2011 20:35
After installing the extension I get an error every time I start to edit a CSS file. After clicking OK to dismiss the dialog everything seems to work fine. I don’t get this error when editing HTML5, only CSS. It doesn’t seem to matter what version of CSS is selected in the editor drop-down list. I logged the error as the dialog suggested, below is the relevant (i.e. only) error line from the log file:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index at Microsoft.VisualStudio.Text.Implementation.SimpleStringRebuilder.get_Item(Int32 index) at Microsoft.VisualStudio.Text.Implementation.TextSnapshot.get_Item(Int32 position) at MadsKristensen.WebEssentials.ColorSmartTagger.GetRealSnapshot(String classification, SnapshotSpan currentSpan, ITextBuffer buffer) at IntraTextAdornmentSample.ColorTagger.<GetTags>d__0.MoveNext() at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.<GetTagsForBuffer>d__16.MoveNext()


I hope this helps track down this problem, I appreciate the extension!

Joe
November 14, 2011 14:43
Should be baked into vs.
November 14, 2011 20:02
@Joe Paris,

I can't repro the issue. Can I get you to send me the CSS file that causes this issue to madsk at ms dot com, please?
November 15, 2011 20:51
@Mads Kristensen

I sent you the zipped project twice but got a delivery error message both times. Did you get my e-mail(s)?
November 15, 2011 21:52
@Joe Pars,

I haven't received anything yet. Are you sending to madsk at microsoft dot com?

Also, there are a lot of fixes in version 2.5 which I released 5 mins ago. That might fix it for you.

Thanks again
November 16, 2011 1:41
@Mads Kristensen

That is where I was sending it, via the Hotmail web interface. Your mail server wouldn't kick it back because of the attached .zip file, would it?

In any case, I will try the updated version when I get home tonight and, if the problem persists, will try e-mailing a different way.

November 16, 2011 13:21
@Mads Kristensen

Sure enough, the update seems to have cleared up the problem! Thanks for being so willing to help.
November 21, 2011 11:55
+1
It is cool, but not sure whether it will cost lots of CPU and other resources or not. I've already installed 5 ones.
January 25, 2012 22:41
Holy crap! I was still uploading each of my images and converting them to base64 before embedding in the stylesheet. What a time saver. Oh, and the live preview looks awesome. Definitely get this in the next version of VS.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.