Navarr's Tech Side The Technical Side of my Life

12Jan/100

Never Again (External JavaScript in the Body)

This is probably simply a personal taste, but I hate putting External JavaScript tags in the body of a web page.  It feels and looks very unsightly to me.  But as I learn more and more JavaScript, and really start to get a feel for the small language, I’ve realized that I don’t have to.  That it’d be just as easy to place them directly into the header after the page is ready, by manipulating the DOM.  Here is an excerpt from the beta turled website.

$(document).ready(function() {
	// Google Analytics
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	var script = document.createElement("script");
	script.src = gaJsHost + "google-analytics.com/ga.js";
	script.type = "text/javascript";
	document.getElementsByTagName("head")[0].appendChild(script);
	try
	{
		var pageTracker = _gat._getTracker("CENSORED");
		pageTracker._trackPageview();
	} catch(err) { /* Do Nothing. */ }
 
	// Facebook Share
	var script = document.createElement("script");
	script.src = "http://static.ak.fbcdn.net/connect.php/js/FB.Share";
	script.type = "text/javascript";
	document.getElementsByTagName("head")[0].appendChild(script);
});

As you can see, I wait until the document is loaded using jQuery’s ready method, and then create elements for both Google Analytics and Facebook Share, before appending them directly to the <head> of the website.  Keeping the code clean, reducing bandwidth usage for non-JavaScript users, and even making Google’s code cleaner.  (By changing Google Analytic’s default code from document.write to DOM Manipulation.

So, Never again will I feel the need to insert external script tags at the bottom of the <body> just so that the rest of the page loads before them.

Note: If you’re not using jQuery, document.onload = function() { /* Code */ } works just as well, I promise.

12Jan/100

How Google Could Change The Industry (And Take Over Your Life)

So, the one thing that you’ll find on any and all news websites who are of any quality at all would be the brand new Google Phone, the Nexus One – the one device that’s making me cringe and go “WHY DIDNT I CREATE A YOUTUBE SHOW BEFORE NOW?” Since, you know, just about every single YouTube partner has gotten a free Nexus One.  FEEL MY ENVY, YOUTUBERS.

But, there is definitely one thing that could be different.  One thing that they could change the entire industry with.  And all they’d have to do is partner up with cell phone providers, and convince them to let you get an account without a phone number.

What?  What’s that Navarr?  You’re absolutely INSANE!  You can’t get a cell phone without a cell phone number?  Why would you want to?  What possible use could that be?  What would you do??

Well, if you really are asking all those questions, than shut the hell up and think for a moment.  What two things does Google own that would allow them to do something so spectacularly crazy?

Google Voice, and Gizmo5.  Gizmo5 would only be necessary if they decided to do Voice over Data, which I personally am not sure the cell phone backend is ready for – but could you imagine purchasing a Nexus One, signing in with your Google (apps?) Account, and then if you already have Google Voice it simply works?  And if you don’t it gets you started on creating an account, including choosing your own phone number (for life, although changeable).

Google would store your basic account numbers and information, and if you ever wanted a new android phone, you would simply log in.  It’d automatically use your phone number and all your other details, too.

Maybe though, just maybe Google could do this – and make actual cellular calling free, with the only thing you’re paying for being data.