For 2 days I've been looking an answer, but I can't find a good solution to my problem.
What I'm trying to achieve is to add an
<script> tag to my HTML, but with a timestamp added as a variable, such as:
With PHP it would be simple to achieve, because you can just add the timestamp along with the HTML. But since I must work with front-end code only, what would be the best way to add a
link tag with a timestamp, so the script doesn't get loaded from the cache?
Since the client uses Internet Explorer 10, I will need an answer that will work with that...
Could anyone help me out?
While creating an element, setting the attributes and appending it to the document kind of worked, the beforeSend headers weren't set on the AJAX calls in the
I suddenly realised that I could try a simple
document.write() within a script tag. Turns out that it works like a charm.
(I can't believe I couldn't come up with this solution earlier)
Since you are working with jQuery I recommend you to do it this way:
From jQuery docs:
By default, $.getScript() sets the cache setting to false. This appends a timestamped query parameter to the request URL to ensure that the browser downloads the script each time it is requested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!Donate Us With