javascript - Can I cache contents loaded by jQuery.getScript() -


as per jquery documentation (https://api.jquery.com/jquery.getscript/) use more flexible $.ajax() method, doesn't work me described in here (jquery cannot load plugin file using ajax before calling plugin function, thus, gives kind of weird result)

by default, $.getscript() sets cache setting false. appends timestamped query parameter request url ensure browser downloads script each time requested. can override feature setting cache property globally using $.ajaxsetup():

$.ajaxsetup({   cache: true }); 

but need cache few of contents not all.

alternatively, define new method uses more flexible $.ajax() method.

it didn't work me doesn't guarantee loading files in sequence.

now best solution situation?

use $.ajax datatype: 'script' , cache: true.

$.ajax({     cache: true,     url: 'foo.js',     datatype: 'script', // optional, can omit if server returns proper contenttype js files.     success: function () {         console.log('hello world!');     } }); 

this assumes server responding headers required browser cache file.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -