bing on bling

Jun 04, 2009 0 Comments
Tagged: , , , and

bing.com is the new search engine of microsoft. It could be great with the amount of smart people at Microsoft and the amount of money thrown at it. The search results are what you expect from any decent engine (a search for wnas puts me on top). But what got me baffled is the markup of the page, which comes in at a hefty 26,708 bytes. And that for a page which has one input field and some links... Me as a front end developer, I'm baffled by that size and kinda insulted. I have to wait longer because they used front page or what ever, no way, not in 2009 I don't.

The real fun comes when you do a certain magic trick called view source. Most of the size of the HTML is being formed by inline css and javascript. There even is a table in there, along with inline script handlers...

1999 called and it want's it's markup back, guys.

The numbers

Still I get back to the size of the page, a whopping 26,708 bytes with all the bells and whistles. If you strip the javascript alone, you're still left with just 13,462 bytes.

Thats 13,246 bytes of inline javascript for you.

So no javascript solves the size and the waiting time? Not quite, we have inline css too. So if we get rid of that, we are left with 5,524 bytes.

So the css alone is 7,722 bytes.

It seems that were getting there, no. No way, the html is very much too much and can be optimised to I think half of it's current size.

That size being 5,524 bytes for HTML alone.

If they got the correct markup and got their CSS and JavaScript from external sources, the user would only had to download that once. And would get a better experience, because faster is better.

Conclusion

I think that the front end of this page was build by a .net developer, who thinks everybody got a broad band connection. Maybe that is the case, but I know that my patience is less now than it was when I had a 14k4 modem. If I have to wait, even for a few seconds, it's not my fault and the chance that I navigate away from that page would be greater now than it was back in the 14k4 days.

So Microsoft, please clean up your act and hire a decent front end developer. Maybe you could look at this awesome presentation from Nicole Sullivan at yahoo. It shows you how much speed matters.

Textmate plugins

In my work I use textmate, the mac only editor from macromates. It comes with the abilities for macro's and plugins, some of them are in my opinion very usefull for a web developer.

CSS

For CSS I absolutely love this one Format CSS single-line. With this you can format your CSS in the way you prefer, simply by pressing ctrl-q.

You choose either 1 or 2, where the latter is the single-line option you should go with when you publish stuff.

JavaScript

Another one is for writing javascript, the one thing that makes it usefull to me is that it runs jslint on my js as I save. That sort of thing keeps me sharp and makes me put ; in all of the right places. It warns you, nice and unobtrusively, of any warning or errors as you save. And you can call it before that to get a nice window, where you can click right through to the line where the error is.

validate

It also compresses your JavaScript files in two ways, minifying or obfuscating it. You can get it here: Javascript tools.

@media 2009 and other conferences

This year I will be attending some conferences, here is my list of the ones I will be going to.

@media 2009

In a few months I will be attending my 6th (sixth) @media conference. This time I booked a room in the hotel which is the closest to the venue, the Premier Inn London County Hall. No more wandering around london in the rain, as I did after a few pints at the first @media ajax november 2008. No more standing in cramped underground trains as I did at my last company sponsered visit in spring 2008.@media 2009

I am looking forward to seeing all of the speakers, especially the ones I haven't seen like Simon Collison and Jason Santa Maria. I'm curious on the one track arrangement, as I always had a love hate relation with the two track thing. Two of my favorite speakers would always be on the same time in a different room. I am not sure that I like the whole no-lunch thing, but I understand that the guys from vivabit had to do something to keep is affordable in these times.

Still the cost of a conference to me is not the ticket alone, I have to fly over and get a hotel for a couple of nights. So the cost of the ticket is only 40% of the whole, less so if you reckon that I won't be billing clients for three days. But the real value is off-course in the speakers and speaking to lots of fellow web developers from all over europe and to that I am really looking forward to.

Fronteers

The other conference I am going to attend is Fronteers 2009. Not that I have much of a choice as I have been drafted by PPK to help organizing the whole thing. One of the advantages is that I already know which speakers we have lined up. All I can say at this point is that you really, really have to attend this one..

fronteers

Full frontal

The third one I may attend is Full frontal as the speakers line up sure looks impressive for a day which costs only 100 pounds. I am not sure about this as it comes awfully close after fronteers and I may have some work to do sometime. On the other hand this could be my replacement for my yearly javascript conference fix that @media Ajax provided...

So if you are attending any of these, have fun and I will see you there.

jQuery UI slider

The past few weeks I had a lot of fun playing with jQuery UI for a client. They wanted to replace some elements in an application, sliders and such, with a more accessible solution. For that I turned to jQuery UI, as I had previously introduced jQuery as the standard javascript library for them.

As I started to play with the code I couldn't helped but be impressed by the great work that has been done by the UI team on this project. But as I looked at it more closely I found some things that could be improved.

So here are some of my grieves with it and a possible way to solve them. I am going to concentrate on the slider ( docs / demo ), as it was with that widget that I started to notice some things missing.

The way you use it is in a true jquery fashion nice and unobtrusive, once you have included the correct javascript files (for that see the documentation), you just do:

$("#slider").slider();

And shazaam, #slider has turned into a slider, nice... But, what happens to the input that people provide...

This solution is nothing without javascript, so in my book it is a nono. I can not imagine that I could use this widget on my sony erikkson k800 phone. So accessible it is not, at least not in the way the demo shows us. And as most people will just copy and paste from demo's, most sliders will not be accessible.

So what you say, a slider can never be accessible, rubbish I say. Stick with me and I will show you a very simple way to make this accessible. And in a few day I will put up some example sliders to accompany the code as suggested by Danny Lagrouw.

Improvement

First we will look at what a slider does, it provides a user the possibility to enter data. Whoa, a whole new concept... eh no.

Lets start with an simple < input type="text" /> that gives people a good opportunity to enter a value, no? But what about stepping you say, that we can solve with a few < input type="radio" />. All we have to do is write javascript that sends the value of the slider to the input and when the form is submitted, the server can sort it out.

If a user has no javascript a viable alternative is provided. So not only advantages on the user level, but did you notice that we just solved the data to server problem, in a way that requires us to write zero I admit it is boring but if you want your fancy interface to do something, it has to interface with the back-end as well.

So we start with the html, as that is the base for accessible solutions, we set up a free form slider. As we do this, we make sure that we create a fully functional option for everybody. That is, the purpose of the slider is to set a value.

<div class="slider free" id="slider">
<label for="text">
label
</label>
<input type="text" id="text" />
</div>

As you see a nice and clean solution where data can be entered and processed. What we miss is the fancy slider, which we will create with javascript like this:

// add a slider container div
// add a slider handle to slider container
// place a span to recieve the value
// and add a class to the container
// find and set the input to readonly
jQuery('.slider')
.append('<div class="slideContainer"> // br
<div class="ui-slider-handle""> // br
</div> // br
</div> // br
<span class="value"></span>') //br
.addClass('sliding') // br
.find('input').attr("readonly","readonly");
// linebreaks (br) added for readability

There you have it, an accessible solution for a slider, simple as that.

But wait, what if I have 5 steps that I want people to choose from. That I cannot do, so your solution sucks and I still am stuck with a pure javascript solution says the sceptic (I know who you are...). Oke, the second one is a slider with steps for you.

First let us see what that is, it is simply a option you choose from a limited number of options isn't it. The html solution for this is really easy, radio buttons. So of we go with html

<div class="slider steps" id="slider2">
<fieldset class="radios">
<legend>legend</legend>
<input type="radio" name="radio" value="0" id="v0" />
<label for="v0">zero</label>
<input type="radio" name="radio" value="1" id="v1" />
<label for="v1">one</label>
<input type="radio" name="radio" value="2" id="v2" />
<label for="v2">two</label>
<input type="radio" name="radio" value="3" id="v3" />
<label for="v3">three</label>
<input type="radio" name="radio" value="4" id="v4" />
<label for="v4">four</label>
</fieldset>
</div>

Just like that we have a viable and accessible solution in plain old semantic html, now for the javascript.

var sliderSteps = {
radiobuttons : ((jQuery(this) //br
.find('input[type="radio"]') //br
.length)-1) //br
.toFixed(0),
init : function(targ){
sliderSteps.createSlider(targ);
sliderSteps.set(targ)
},
set : function(targ){
var w = (100/((sliderSteps.radiobuttons*1)+1));
jQuery(targ) //br
.find('label, .ui-slider-handle') //br
.width(w+'%');
},
createSlider : function(targ){
jQuery(targ).slider({
// zoveel stappen als er radio button zijn...
steps : sliderSteps.radiobuttons,
change:function(e,ui){
var x = jQuery(this).slider('value');
var a = (x/100*((jQuery(this). //br
find('input[type="radio"]').//br
length)-1)).toFixed(0);
// set the value somewhere...
jQuery(this).find('.value').text(a);
// check the radiobutton.
var t = jQuery(this). //br
find('input[@type="radio"]')[a];
jQuery(t).attr('checked','true');
}}
);
}
}
sliderSteps.init('#slider2.steps');
// linebreaks (br) added for readability

So there you have it, a nice clean and accessible slider solution for the folks at jquery ui to include in their demos. And for everybody else to look at and maybe even use. So have fun with it and let me know if you like it.

If you see any faults in the code please let me know, but as I am on holiday now, don't except me to rush...

Here is all the demo code zip file wn.slider.zip for you to play with.

Technorati Tags:, , ,

Opera is helping people

Chris Mills of opera has just published great resource for web developers. In this he talks about best practices and tries to get people to unlearn stuff like:

In the old days, people used to do things like laying out their web sites inside giant tables, using the different table cells to position their graphics, text etc (not what tables were intended for, adds superflous markup to the page). They used to use invisible images called spacer GIFs to fine tune positioning of page elements (not what images are intended for, add superfluous markup and images to the page).

So go and check it out, it sure is a great resource and will get better.