Pro Tip: JavaScript

Here is a good tip in JavaScript to reduce some bytes in your code.
When declaring an array with more than 5 elements,
make it a string and use the split function.

Example;

//48 bytes
var a=["a","b","c","d","e","f","g","h","i","j"];
//39 bytes
var a="a|b|c|d|e|f|g|h|i|j".split("|"); 

The split function in this case provides almost 20% less code. I recommend more than five elements for this process, because less than that you are worse off because of the added characters for .split(” “).

For every element you add in the first example, you add 3 characters to seperate the elements.

","

The second method uses only one character per additional element.

|

Just think how much you can reduce your code if you have arrays with a large number of elements.

Get Google Drive, Keep Dropbox!

 

With the launch of the new Google Drive, a lot of people are making the switch, myself included. The first problem I found very quickly though was that I have shared folders on Dropbox that others are still using and uploading to.

My solution, put dropbox inside of my Google Drive.

First step, click on preferences on the Dropbox context menu, the icon in your system tray.

Next, select the “Advanced” tab in the Dropbox preferences, and click on move.

Now, Google Drive is flagged as a system folder and Dropbox will not let you select it directly, you will have to add a sub folder.

That is it. You now have Dropbox inside of Google Drive (on this computer anyways).

Pro Tip of the day

I guess I should be adding more content more often, eh?

Well, I just came back from #innovate2011 conference in San Francisco, and had the chance to meet and listen too Christian Heilmann (@codepo8) who works at Mozilla.

The one thing that I really took away from his talk came in the Q&A part. The question was asked, “With HTML5, how do I build something that works in IE7?”. Great question right? Christian gave a great answer, that I never though off, and admittedly have ignored before, “Don’t, you don’t have to”.

Christian continued to explain you shouldn’t limit yourself when developing a site. If you have the ability to create an amazing WebGL application, DO IT! There are ways to check if the browser supports what your doing, and if it doesn’t then the user doesn’t see it. Use tools like Modernizer to do feature detection (not browser/device detection!). Build your amazing WebGL thing, and if the user is not using a browser with support put an image in it place; Christian’s idea was to put in an image with text that said “This could be so much cooler if you had a better browser”.

So with all that said, Go out and build your better sites, and just put in fall-backs, crappy fall-backs. Maybe then users will make the switch and we won’t have to worry about it.

Chrome for developers

Came across some great videos from Paul Irish, developer at Google, about some great features inside of Chrome DevTools. On the blog over at HTML5rocks.com, Paul describes how you can take advantage of great tools, like console.dir(), which helped out a lot. In the post he also talks about some new DOM Apis, check it out.

http://updates.html5rocks.com/2011/09/7-minute-videos-Javascript-Console-Protips-newish-DOM-APIs