When using plain js ajax, the jsapi
google library could be lazy loaded via ajax
as follows:
$.ajax({
url: 'http://www.google.com/jsapi',
dataType: 'script',
cache: true, // otherwise will get fresh copy every page load
success: function() {
google.load("visualization", "1", {packages:["corechart"]});
}
});
Here you can set the cache: true
attribute.
Question: how can I set this attribute in a normal <script>
tag?
Problem: I'm lazy loading the library in angularjs
as follows on request:
var script = document.createElement('script');
script.src = '//www.google.com/jsapi?callback=callback';
document.body.appendChild(script);
Every time the page is accessed, the library is fetched again from google. It's never cached. Is it possible to enforce caching here?