Ops, typo if(l && l.getItem(y)) f(l.getItem(y))(); else { var $ = this.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest; $.open("GET", y, false); $.send(null); $ = $.responseText; if(l) // I would use clear here if this is the only cached script l.setItem(y, $); f($)(); }; })( this.Function, this.localStorage, "scripts/jquery.1.3.2.min.js" );
On Thu, Aug 20, 2009 at 7:53 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > jQuery minified and gzipped is already light, if about 15Kb of bandwidth > are a problem I think the main problem is the server itself. > > Moreover, using common and well known techniques to cache scripts could > avoid bandwidth usage at all or thanks to Web Storage you can implement > something like this directly in the page to avoid server calls: > > <script type="text/javascript"> > (function(f,l,y){ > if(l && (l = l.getItem(y))) > f(l)(y); > else { > var $ = this.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : > new XMLHttpRequest; > $.open("GET", y, false); > $.send(null); > $ = $.responseText; > if(l) > l.setItem(y, $); > f($)(); > }; > })( > this.Function, > this.localStorage, > "scripts/jquery.1.3.2.min.js" > ); > </script> > > If you do not use localStorage.clear you can use whatever jQuery version > until the next release sending it via gzip once for each visitor. > > Regards > > > > > On Thu, Aug 20, 2009 at 4:23 PM, DBJDBJ <dbj...@gmail.com> wrote: > >> >> @ludovic >> >> If I understood you right you are supporting conditional compilation >> idea, but done in jQuery? >> Can you elaborate please? >> >> Am I right in thinking that this can lead to a very clever system, >> that will increase every page HTTP GET time ? >> >> It is relatively easy to imagine and implement a little jQuery loader >> that will load up additional needed parts, in accordance with which is >> the browser host. Dynamic composition? Very modern term ;o) >> >> PSEUDO CODE : >> >> // at this point only minimal jQ is loaded >> $( function () { >> // load jQ part 1 >> if ( is_supported_X() ) $.getScript ( .... ) else $.getScript >> ( .... ) ; >> // load jQ part 2 >> if ( is_supported_Y() ) $.getScript ( .... ) else $.getScript >> ( .... ) ; >> // load jQ part 3 >> if ( is_supported_Z() ) $.getScript ( .... ) else $.getScript >> ( .... ) ; >> // load jQ part 4 >> if ( is_supported_W() ) $.getScript ( .... ) else $.getScript >> ( .... ) ; >> // and so on untill we have assembled all we need >> }) >> >> This could be at the bottom of the single minimal js file needed ... >> AFAIK, Dojo, ExtJs etc ... all have a conceptually simillar mechanism >> for dynamic and transparent addition of necessary parts. >> >> --DBJ >> >> On Aug 20, 2:32 pm, ludovic <ludothebe...@gmail.com> wrote: >> > Another point to add : >> > Even if two different browsers respond to the same features detection, >> > one browser can only correspond to one combinaison of features >> > detection. I understand that in developpment, it is cleaner to use >> > features detection, but there should be a compilation for most used >> > browsers. >> > >> > We don't even need to make it for every browser. Just for IE 6, IE7, >> > IE 8, FF2, FF3.0, FF3.5, Safari 3.1 and some others. >> > If the browser doesn't correspond to one of precomputed files, it will >> > simply download the full file as we do actually. >> > >> > In a certain way, it is the creation of a precompiler like //@cc_on >> > but enhanced. >> > >> > Regards >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---