Sunday, March 30, 2008

running scripts before binary content load

I just finished banging my head against some problems in the delver application.

One of them, a really pesky one, is that JS functions assigned to the document.onload event will not start running until all binary content finished loading.

This causes the UI not to respond until all images are loaded.

I looked around for a solution for quite some time and finally i found one!
Dean Edwards - YOU DA BOMB!

I took the solution he created and packaged it into a function i could use whenever i need to defer my JS functions before binary content load, and here it is:


function loadScriptsBeforeImages(func){
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", func, false);
}
/*@cc_on @*/
/*@if (@_win32)
document.write("<\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
if (this.readyState == "complete") {
func(); // call the onload handler
}
};
/*@end @*/
if (/WebKit/i.test(navigator.userAgent)) {
var _timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
clearInterval(_timer);
func();
}
}, 10);
}
}



All you need to do is call loadScriptsBeforeImages(functionToExecute) and pass the function name you wish to defer as a parameter.

In this case, i'm calling an init function to attach methods to some DOM objects.
Notice the first two lines of the function which prevent the methods to run more than once.



function functionToExecute(){
if (arguments.callee.done) return;
arguments.callee.done = true;
method_1();
method_2();
method_3()
}





i hope this helps someone out there...

Sunday, January 13, 2008

new script for IE5-6 that makes my life a little better

I just got word of some new scripts (ie7.js and ie8.js) that make older IE versions behave like they were IE7 or IE8 (standards-wise).

i am checking them right now and will come back with some more in-depth analysis, so stay tuned.

here is the link for the scripts, brought to us by Dean Edwards.

Tuesday, November 27, 2007

Client-side learning milestones

After reading Dor's comment and talking to him (and some other co-workers in seeking alpha) i have decided to allocate some time and compile a list of steps one should follow in order to start his way in client side development.

these steps are only the first ones and do not make one a client-side professional - but they do give one the basic grasp of things.

so there it is - The List™:


  1. first steps (basic HTML and CSS):


    HTML dog

  2. understanding the CSS positioning models:


    brainjar (CSS section)

  3. introduction to the DOM (Document Object Model):


    brainjar (DOM intro)


those are the first steps - more will follow so be sure to drop by on occasion to see if i updated the list (or just grab my RSS...).

Sunday, November 25, 2007

new kid on the blog :-)

hi all!

funny things, those birthdays... people go along with their lives while others open up development blogs for them because they just got fed up with accually hearing what they have to say.

just open a blog and shut up they tell me... :-)

so they opened me a blog...

this is the story of how this blog came to be.

a couple of things about me... will be revealed at a later post not because i'm trying to be mysteriouse but because i'm just plain lazy.

this blog will be dedicated for writing about front-end development (HTML, CSS, JavaScript), usability and good food.

that's it for now, signing off.