- url : A string containing the URL to which the request is sent. It will be URL of your js file.
- callback function : A callback function that is executed if the request succeeds.
So what it does by appending timestamp is, it tells the browser to get a fresh copy of js file every time. In other words, it disables the cache or it doesn't allow browser to cache the js file. Which can be great sometimes but not always.
What if you want to cache the script, so that it doesn't download every time from the server.
Well, there are 2 ways. First is, before making call to $.getScript method, you can set the cache true for ajax request and set it to false once script is loaded.
Second solution is to modify the default implementation of $.getScript to allow cache. The default implementation of $.getScript is,