kilkadg
kilkadg

Reputation: 2317

Why linking an external javascript with ?variable=value

I have seen code like this:

<script type="text/javascript" src="js/my_js.js?id=<?php echo time(); ?>"></script>

I do not understand the reason for the id, nor how to use the id in the .js file, if this is possible.

Thanks.

Upvotes: 0

Views: 88

Answers (1)

lukek
lukek

Reputation: 478

It is to force the browser to refresh the JavaScript file, otherwise the browser may display a cached version at a later date.

You can also do this to CSS files.

Upvotes: 4

Related Questions