Google Maps API - 缓慢加载JavaScript [英] Google Maps API - Slow loading javascript
问题描述
我使用Google Maps API在特定页面上显示地图。
问题在于文件 http:// maps。 google.com/maps?file=api .....
有时会发生加载速度非常慢 - 降低了页面性能,因为JavaScript的其余部分首先在文档准备好时加载, - 因为浏览器锁定等待Google提供的文件。
我试图将JavaScript文件从< head>
标记到我的内容下。但其余的JavaScript从未被解雇,因为浏览器等待Google提供的文件。
有没有办法解决这个问题,或者是否有其他人遇到同样的问题?它最近开始了,我不知道为什么。
这是我的代码,如果有人感兴趣:
< script type =text / javascriptsrc =http://maps.google.com/maps?file=api&v=2&sensor=true& ;安培;键= ABQIAAAAa24xicak8_ghHX58i7La7hRFh9iM79SNC94rOejOtdMRvQmJiBS6Uv5F_1BNSh9ZuSzFXyekHISgew> < /脚本>
< script type =text / javascriptsrc =/ js / maps.js>< / script>
< script type =text / javascript>
$(document).ready(function(){
// Google Maps
initialize();
//其他JavaScript来了....
});
< / script>
如果我访问
http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAAAa24xicak8_ghHX58i7La7hRFh9iM79SNC94rOejOtdMRvQmJiBS6Uv5F_1BNSh9ZuSzFXyekHISgew
文件立即载入。 这是一个相当古老的问题 - 解决办法是禁用萤火虫(至少对我来说)。
I am using Google Maps API to display a map on a certain page.
Problem is that the file
http://maps.google.com/maps?file=api.....
sometimes happens to load very slow - decreasing the page's performance, because the rest of the JavaScript is first loaded on document ready, which its rarely reaches - because the browser locks up waiting for the file from Google.I have tried to move the JavaScript file from the
<head>
tag to under my content. But the rest of the JavaScript is never fired because the browser waits for the file from Google.Is there a way around this, or have anyone else experienced same problem? It began recently, and I have no idea why.
This is my code, if anyone is interested:
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAAAa24xicak8_ghHX58i7La7hRFh9iM79SNC94rOejOtdMRvQmJiBS6Uv5F_1BNSh9ZuSzFXyekHISgew"> </script> <script type="text/javascript" src="/js/maps.js"></script> <script type="text/javascript"> $(document).ready(function() { // Google Maps initialize(); // Other JavaScript comes here.... }); </script>
If I access
http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAAAa24xicak8_ghHX58i7La7hRFh9iM79SNC94rOejOtdMRvQmJiBS6Uv5F_1BNSh9ZuSzFXyekHISgew
The file loads instantly.
解决方案This is a rather old question now - the solution was to disable firebug (atleast for me).
这篇关于Google Maps API - 缓慢加载JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!