简体   繁体   中英

google charts taking long time to load

i'm using google charts google.load("visualization", "1", {packages:["corechart"]});

but the loading time is very slow upon checking the network usage i found that format+en,default,corechart.I.js is taking approx 6 seconds to load. any work around to reduce this time and why isn't this file being cached and every time it is fetched again from the google.

Unfortunately, due to google's terms of service you aren't able to cache/store the library legally.

Your users' computers must have access to https://www.google.com/jsapi in order to use the interactive features of Google Charts. This is because the visualization libraries that your page requires are loaded dynamically before you use them. The code for loading the appropriate library is part of the included jsapi script, and is called when you invoke the google.load() method. Our terms of service do not allow you to download the google.load or google.visualization code to use offline.

Link

I would suggest trying the following:

  1. If you are running the app locally try using a different internet connection or even better, hosting the app to see if this increases performance. It may just be a high latency internet connection.
  2. Attempt to find a place to load the library prior to the view that renders the charts. This may not be a possibility but wanted to throw that out there.

If you are loading other assets over CDN and aren't seeing similar problems then it may be something else. If that's the case I would suggest posting some code so we can see how you are calling the api in your app.

Best of luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM