MSSql MySql Python javascript PHP java DotNet Ruby Hackme Takeawy Code Twitter Facebook

The house of developers, A website to classify and rank developers

 
 
 
 
Country Rank: 2
World Rank: 25
Profile Viewed: 395
Points: 11495
09 Oct 2010

Defer Javascript execution without defer attr

Why do defer javascript execution?

First of all there is a problem of performance, second most time you want to control exactly when a function is executed.

This could be done without defer attribute using data structure specified in json notation:

Then execute at page load all javascript in the order you choose, also calling (using jQuery for example):

var m;
$("."+class).each(function(i,el){
    eval('m.push('+$(el).html()+');');
  });
// one can use m as parameter of a function
$.each(m,function(m){...});
Also it is possible to order data structure by a field (like weight)
Facebook Share Delicious Share Digg Share Google Buzz Share My Space Share Reddit Share Stumbleupon Share Technorati Share Twitter Share

Comments

Please, login or register to add a comment.