0

我想在我的主页显示后延迟加载所有第 3 方 JS/CSS,因为当用户从主页导航到某个特定模块时会使用外部插件等。

到目前为止,我已经成功地将普通 .js 和 .css 外部库比http://wonko.com/post/lazyload-200-released

但是,对于像这样的路径http://maps.google.com/maps/api/js?sensor=true

代码:

   LazyLoad.js('http://maps.google.com/maps/api/js?sensor=true', function () {
   alert('Your JS has been loaded');
   });

我认为解决方案是如何延迟加载网页网址?

4

2 回答 2

0

我相信你想要这样的东西:

$.getScript('http://maps.google.com/maps/api/js?sensor=true');

使用 jQuery。API将提供回调的详细信息。否则谷歌可能有一些机制要求它从加载中出现。只是一个猜测。

于 2013-01-23T09:56:37.133 回答
-1

Found a solution: Check the URL:'http://maps.google.com/maps/api/js?sensor=true' You would find main.js is being imported by it . A simple getScript for sensor=true will not give whole google object so next import also required.

  var t=setTimeout(function(){
    jQuery.getScript('http://maps.google.com/maps/api/js?sensor=true');
    jQuery.getScript('http://maps.gstatic.com/intl/en_us/mapfiles/api-3/10/20/main.js');
  },1000);
于 2013-01-23T11:44:11.707 回答