Browse files

Lazy-load all Google libraries using new JS.Package custom loaders.

  • Loading branch information...
1 parent a248224 commit df4514aace87511f38d387c4e6272c220e9218ac @jcoglan committed May 5, 2009
Showing with 14 additions and 5 deletions.
  1. +0 −1 demo.html
  2. +14 −4 lib/packages.js
View
1 demo.html
@@ -7,7 +7,6 @@
<script src="/lib/js.class-dev/min/core.js" type="text/javascript"></script>
<script src="/lib/js.class-dev/min/package.js" type="text/javascript"></script>
<script src="/lib/packages.js" type="text/javascript"></script>
- <script src="http://www.google.com/jsapi?key=ABQIAAAArVbgzt5nxAQAZ_iB_77caBR-5oywdloojr3wCGctvtY4YLrIFxTp2Uv8Tzdhpc707bQaOPGPEQ3PzA" type="text/javascript"></script>
<style type="text/css" media="screen">
.pinpoint-map { width: 400px; height: 300px; }
</style>
View
18 lib/packages.js
@@ -2,7 +2,14 @@ JS.Packages(function() { with(this) {
var lib = '/lib/',
jsc = lib + 'js.class-dev/min/',
ojay = lib + 'ojay-0.4.0/ojay/',
- yui = 'http://yui.yahooapis.com/2.7.0/build/';
+ yui = 'http://yui.yahooapis.com/2.7.0/build/',
+
+ GKEYS = {
+ '10.0.2.2:8000': 'ABQIAAAArVbgzt5nxAQAZ_iB_77caBR-5oywdloojr3wCGctvtY4YLrIFxTp2Uv8Tzdhpc707bQaOPGPEQ3PzA',
+ 'localhost:8000': 'ABQIAAAArVbgzt5nxAQAZ_iB_77caBQCULP4XOMyhPd8d_NrQQEO8sT8XBTzVWhRwEDkVfNsvzo8bf4ntGV4ZQ'
+ },
+
+ gkey = GKEYS[location.hostname + ':' + location.port];
pkg('YAHOO', yui + 'yahoo-dom-event/yahoo-dom-event.js');
pkg('YAHOO.util.Selector', yui + 'selector/selector-min.js')
@@ -19,10 +26,13 @@ JS.Packages(function() { with(this) {
.requires('YAHOO')
.requires('YAHOO.util.Selector');
+ file('http://www.google.com/jsapi?key=' + gkey)
+ .provides('google.load');
+
loader(function(cb) {
- google.load('maps', '2.x');
- google.setOnLoadCallback(cb);
- }).provides('GMap2');
+ google.load('maps', '2.x', {callback: cb});
+ }) .provides('GMap2')
+ .requires('google.load');
pkg('PinPoint', lib + 'pinpoint-min.js')
.requires('Ojay')

0 comments on commit df4514a

Please sign in to comment.