Minification Made Easy with VS Web Essentials for Visual Studio 2012

Why do we care about minification?

Minification is the easiest thing you can do to your websites to improve the performance of the front end. Minifying is going to take all your code and cram it into one line. This can decrease the size of the file by up to 40%. That is a lot less for your browser to download and will speed up the rendering of your pages.

Why choose Web Essentials?

VS Web Essentials provides the easiest way to setup minification. The extension can be installed without leaving Visual Studio and it’s very easy to find in the extensions and updates portion of Visual Studio. There are no build events to configure. The minification can either happen on save or be done manually. There isn’t a complicated configuration file that you will need to setup. The extension generates an easy to read config file.

Web Essentials provides a TON of features that make CSS and Javascript coding a lot easier. The extension is very useful even if you are not interested in the minification functionality.

CSS Tricks

You can enable an option to prevent the minification from removing CSS comments that have been marked as important. This will allow you to keep your version numbers and licensing in your comments. I’ve tried to hunt down other minification processes that wouldn’t remove important comments and I couldn’t find any.

Javascript Tricks

You can enable Javascript Source Maps that will allow you to use your minified JS file in development and easily find what line bugs are occurring on. Below are some great articles on Source Maps.

This is the first time I’ve done any video demos before. I’d really appreciate any feedback that would help me improve my presentation skills.

Weekend Tech Reads For 3-22-2013

It’s been a little while. I’ve been really busy and been sick. Let’s get this ball rolling again.

Asp.net / Asp.net MVC

@Html and beyond – This article goes over extending the HTML helper in asp.net MVC.

Web Development

FIVE THINGS YOU CAN DO TO MAKE HTML5 PERFORM BETTER
Native form elements – This is a great resource for getting all the native form element types. You can also use this to see what browsers support what HTML5 elements.
How to Lose Weight in the Browser – This is a really great guide to learn how to optimize front end performance.

Windows 8: H8ers gonna H8

I’ve been running Windows 8 for several months now. All I see on the net is a bunch of hate for it. I’ve been trying to read these with an open mind, but most of them are just ridiculous. Even I believed the “Every other OS is junk” theory. I still feel that Vista wasn’t great, but it wasn’t nearly as bad as what people thought. It was awesome if you had a beefed up dual core PC. Making fun of Microsoft products is far past beating a dead horse. IE9 and 10 are awesome, but nobody knows that because they are too busy using Chrome or Firefox. A lot of people don’t like change either. Windows 8 has a lot of changes, but I wouldn’t say it’s for the worse. Anyway, I’m going to get off my soap box and go over some of my favorite Windows 8 features.

It boots super fast.

I don’t think I’ve ever had a computer boot as fast as my Windows 8 machine. I use to go and get coffee when I was booting up in Windows. I now generally just get my iPad out and check my email on it.

You don’t need your start menu

I’ve seen a lot of people complain about their start menu being gone and how everything has to run in the Metro style theme. You can avoid the Metro styled stuff completely if you don’t want to use them. The start menu is replace with a start screen that provides a really good visualization of your apps. It’s very easy to customize and much more usable than the original start menu. I have almost no desktop shortcuts now. I had about 15 items pinned to my start menu and was about the height of my screen. I got rid of my quick launch bar because it’s faster to use the new start screen.

Cloud Saving Your Settings

I use to always do a bunch of stuff to have consistent desktops, lock screens and stuff. Windows 8 saves all these things to the cloud. I signed into a Windows Surface tablet and everything came down without needing to do anything. This is a really minor thing, but it is one of those small nice to have items that gives Windows 8 a great fell.

Great Multi monitor Support

Holy cow, the multi monitor support in Windows 8 makes it completely worth the upgrade. You can span your task bar to every screen and the task bars will only show what applications are on that screen. This was a feature in a tool called UltraMon that I really liked using. It makes multi monitor multi tasking really easy.

I really feel like Windows 8 is a step in the right direction. You have to be willing to accept change and put a tiny bit of effort to learn how to do some stuff again, but it’s totally worth it.

Weekend Tech Reads For 2-1-2013

Asp.net / Asp.net MVC

Visual Studio: Web Dev Bliss – This goes over the basics of Visual Studio’s web development capabilities.

Javascript / jQuery

Parsley.js – Parsley is a really great and simple validation framework.
Do You Know When You Are Looping in jQuery?

Web Development

Beginner HTML5, JavaScript, jQuery, Backbone, and CSS3 Resources
What’s Hot in the World of JavaScript and SPAs?
Talks To Help You Become A Better Front-End Engineer In 2013

Weekend Tech Reads For 1-25-2013

Asp.net / Asp.net MVC

Simple way to bind an Enum to a DropDownList in MVC

Javascript / jQuery

I’ve noticed a bunch of map files showing up in my solution file. I wasn’t really sure what was up until I saw these articles come through.
The Magic of the jQuery 1.9 Source Map

Source Maps 101

CSS

Coding Q&A: CSS Performance, Debugging, Naming Conventions – This is a really good article about CSS performance and it includes a lot of slide decks.

Getting Started With Twitter Bootstrap – I used Twitter Bootstrap for the first time this last weekend. This article came out about three days afterwards and I really could have used it.

A 24 Hour Hackathon And My Experience.

I can say I’m no stranger to 24 hours of straight work. It has only happened on a handful of occasions and was typically to meet a deadline. On January 18th from 5pm to 5pm the next day, I participated in a 24 hour Hackathon. I was on a team of six and our goal was to build a website to serve a very specific need. We successfully hammered out a fully functional product that would have taken at least a month of development under normal circumstances. Here are my experiences and learnings from the event.
Continue reading

Weekend Tech Reads For 1-18-2013

Asp.net / Asp.net MVC

Ten Tricks for Razor Views – Great post on some syntax related stuff with Razer views in MVC. This is really helpful if you have only been using the standard view engine in MVC.

Javascript / jQuery

WAAAAAAAYYY too much stuff has been going on with jQuery this week. It’s really awesome stuff though.
JQUERY 1.9 FINAL, JQUERY 2.0 BETA, MIGRATE FINAL RELEASED
Announcing jQuery Mobile 1.3.0 Beta
ANNOUNCING THE JQUERY PLUGIN REGISTRY

Web Development

The Best Way to Learn HTML – This is a great article for beginners.
Learn Advanced HTML & CSS with one useful guide.

Weekend Tech Reads For 1-11-2013

Asp.net / Asp.net MVC

Announcing the ASP.NET and Web Tools 2012.2 Release Candidate – A bunch of new features coming to Visual Studio.
Creating a complete ASP.Net MVC 4.0 application with Visual Studio 2012, C# , EF 5.0 (Code First) – part 1 – Great read on creating an MVC 4 with EF.

Javascript / jQuery

Essential JavaScript Namespacing Patterns – It is well known that Addy Osmani is my javascript hero. This article changed my methodology for coding javascript.
jQuery API Documentation – The jQuery API Documentation got a face lift recently. I find it much more usable. jQuery UI also had an update recently.

CSS

All you need to know about CSS Transitions – CSS transitions have always stumped me. I’ve always relied on javascript for animations. This gives a great overview.

Web Development

Web Developer Checklist – This is a checklist that every web developer should checkout. It provides you with a basic check list of all the things you need to look at while building a website, but also gives you links to help you out with each item.

Other Reads

Windows 8 productivity: Who moved my cheese? Oh, there it is. – Article by Scott Hanselman about where some stuff has been moved and new features in Windows 8. This is a really good read if you are new to Windows 8.

Lessons Learned And Tips – Responsive Design

I recently came off my first project where I got to fully implement a responsive design for a desktop to mobile website. I’ve done several in the past where we would do certain things for portrait and landscape or tablet to mobile design. I feel desktop to mobile was defiantly more challenging. The project was a huge success and there was excellent work by all teams, but there were several few “gotcha” moments that almost happened. These weren’t due to lack of attention to detail, but more along the lines of new discoveries. I’m going to outline some things that we executed that helped out greatly and a few other things that caused some headaches.

Keep the layout simple

Look at your site content before you begin to implement a responsive design. Can you present all of your content in one column and it still be relevant? You may want to look into a full mobile implementation if you can’t do this.

You can always use Javascript and CSS to show hide content based on screen widths. I’d recommend using caution when going wit this approach. You shouldn’t be hiding more than you are showing.

The Boston Globe is a great example of appropriate use of a responsive design.

Be careful with date pickers

Ever try to use the jQuery UI date picker on a mobile phone? It’s not fun. You can set the input type of your text box to “date” so that a mobile phone will open the native date picker. However, some desktop browsers support date inputs and we didn’t want double date pickers. I found an article on how to handle HTML5 and the jQuery UI date picker here.

Avoid CSS Clear Fixes

Yeah, I’m guilty of this like crazy. It’s a quick fix, but can be really killer when you need to restructure how the elements align on the front end. Instead of using a clear fix, you can apply an “overflow” with a value of “auto” or “hidden” to the parent wrapper to get the same effect. This is the best article I’ve found explaining CSS floats

Watch your device dimensions

For the longest time phone screen dimensions were 320 by 480. The iPhone 5 and Galaxy S3 have been released and their screen sizes are a little bit different. The iPhone 5 has a size of 320 by 568 and the Galaxy S3 is 360 by 640. Yes, I know their specs say different, but this is if we set their pixel density to 1 instead of 1.5+ (retina). The old methods aren’t reliable anymore. We must remain flexible in the mobile world. I’d recommend portrait going to 479px and landscape going to 767px. This IS stepping on smaller tablet’s toes. The Kindle Fire would pickup our mobile landscape mode. So figure out what will suite your needs best. This is a good example article with some media query snippets to use as a starting point. You will need to tweak for more modern devices, but the logic remains the same.

Keep the background repeatable

See the above note. Fancy background images can be problematic when you try to stretch a background to fit all phone dimensions and look crisp. I recommend solid colors, gradients or an image that repeats horizontally well.

Avoid using img tags

This mainly applies to using icons. Trying to dynamically change image tag source attributes can’t be done in CSS and you would have to rely on javascript. I recommend using a block element like a div tag and setting the background to your image. You can then change the background image in CSS when your mobile layout is applied. If you are working with an instance where an image tag was already implemented, wrap it in a div, hide the img tag when in mobile and set the div’s background. It’s not the most graceful approach, but will work if you are in a pinch.

Rely on CSS more than Javascript

This is probably the biggest thing I learned. Do your best to keep all your responsive design related stuff inside of CSS and use media queries to determine when to load them. I’ve seen sites use javascript to determine if the screen is landscape or if it is a specific width by attaching an event to window.resize. This can result in a really glitchy experience if the user manually re-sizes the window.

I hope you found this post useful for your next responsive design project. Thanks for reading.

How to use cloud storage services to sync saved games across PCs

I’m a big fan of playing games over my lunch break. It is a great way to unwind for an hour or so before. Minecraft is probably my favorite one to play right now. I ran into an issue about a year and a half ago when I first started playing Minecraft. I wanted to be able to play my worlds on my home PC in the evenings and play them on my work laptop during lunch. Many services now, like Steam, offer cloud based game saves. I had to hunt down a method to do this for games that fell outside of this realm. I was already using Drop Box for cloud storage and I found a few articles on how to use it to use it for your Minecraft saves. I wanted to take it to the next level. You can use a symbolic link to link two folders together and share their contents. You just need to use the mlink command in the command line with the folder paths to create this link.

mlink /d "target" "source"

Your target file location must not exist or you will get an error via command line. I created a batch file that is in my Drop Box folder that I run whenever I hop onto a new PC that I want to play Minecraft on. I link my entire Minecraft directory so that my mods, texture packs, settings and saves get shared to all my computers. To get my batch file to work correctly, you will need to remove your .minecraft folder from you app data folder and move it to your Drop Box.

mklink /d "%AppData%\.minecraft" "%HomePath%\Dropbox\Minecraft"
pause

%AppData& and %HomePath% are environment variables. %HomePath% automatically maps to your user directory. EX: C:\Users\WorthyD\. You can find a list of environment variables here. They can be really useful when setting up these link files.

Here are some of the other links I’ve used.

Elder Scrolls: Oblivion
mklink /d "%HomePath%\Documents\My Games\Oblivion" "%HomePath%\Dropbox\Oblivion Saves"
pause

Warcraft 3
mklink /d "%ProgramFiles(x86)%\Warcraft III\save" "%HomePath%\Dropbox\WC3 Saves"
pause

Remember that you will need to move your original save files to your Drop Box folder before running these commands.

Hope you find this useful. Thanks for reading!