Redvex3
Benvenuto visitatore
Login Registrati
Spinner
Risparmiare banda grazie alle google api :)
Grazie a google abbiamo la possibilità di far caricare le librerie ajax dai server di google dando una bella accellerata alle nostre applicazioni e un risparmio notevole in termini di banda consumata.

Spesso i framework JS sono tra i maggiori carichi sui server delle applicazioni ajax. Avvolte, tra l'altro, la loro pesantezza rallenta le applicazioni e crea problemi. Grazie a google questi problemi non esisteranno più, da 1 mesetto circa è infatti possibile caricare i framework tramite le google api addirittura scegliendo quale versione caricare. Tutti i framework sono in versione compressa per risparmiare quanta più banda possibile.

Per esempio se vogliamo includere prototype e scriptacoulus nelle nostre applicazioni rails sostituiamo

<%= javascript_include_tag :defaults %>

con

<script src="http://www.google.com/jsapi">/**/</script>
<script>
	google.load("prototype", "1.6.0.2");
	google.load("scriptaculous", "1.8.1");
</script>

 

Occhio che il *trucco* vale per la versione 2.x di rails, non sono sicuro che funzioni anche per la 1.2.6 che porta di default prototype 1.5 e scriptaculous 1.7

Le librerie a disposizione sono le seguenti:

jQuery
name: jquery
versions: 1.2.3, 1.2.6
load request: google.load("jquery", "1.2.6");
extras: uncompressed:true, e.g., google.load("jquery", "1.2", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js
path(u): http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
site: http://jquery.com/
note: 1.2.5 and 1.2.4 are not hosted due to their short and unstable lives in the wild...
prototype
name: prototype
versions: 1.6.0.2
load request: google.load("prototype", "1.6.0.2");
path: http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js
site: http://www.prototypejs.org/
script.aculo.us
name: scriptaculous
versions: 1.8.1
load request: google.load("scriptaculous", "1.8.1");
path: http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.1/scriptaculous.js
site: http://script.aculo.us/
note: this library depends on prototype. before loading this module, you must load prototype e.g.:
  google.load("prototype", "1.6");
  google
.load("scriptaculous", "1.8.1");
mootools
name: mootools
versions: 1.11
load request: google.load("mootools", "1.11");
extras: uncompressed:true, e.g., google.load("mootools", "1.11", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/mootools/1.11/mootools-yui-compressed.js
path(u): http://ajax.googleapis.com/ajax/libs/mootools/1.11/mootools.js
site: http://mootools.net/
dojo
name: dojo
versions: 1.1.1
load request: google.load("dojo", "1.1.1");
extras: uncompressed:true, e.g., google.load("dojo", "1.1.1", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/dojo/1.1.1/dojo/dojo.xd.js
path(u): http://ajax.googleapis.com/ajax/libs/dojo/1.1.1/dojo/dojo.xd.js.uncompressed.js
site: http://dojotoolkit.org/

Back
se non sei registrato, registrati per inserire commenti, oppure effettua il login

 
Notizie Mac
 
 
1
PdC Calculator
1 2 3
 
View Gianni Mazza's profile on LinkedIn