Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 850
Baljinder Sekhon Avatar asked Sep 25 '13 07:09

Baljinder Sekhon


1 Answers

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.

like image 148
user2263572 Avatar answered Sep 29 '22 16:09

user2263572