Monday 25 October 2021

External JS Changes Are Not Reflecting | Quick Fix | No Need Of Deleting Cookies & History | No Force Refresh Required


-------------------------------
Convert 
<script src="scripts.js"></script>

To
<script src="scripts.js?version=1"></script>
-------------------------------

Subscribe my Channel:- 
http://www.youtube.com/user/SanketRooney?sub_confirmation=1 

Facebook Page:- 
https://www.facebook.com/UnpossibleNS 

Twitter Account:- 
https://twitter.com/UnpossiblePOG 

Blog:- 
https://unpossiblepog.blogspot.com/ 

Website:- 
https://unpossiblepog.com/ 

Gaming Instagram:- (@unpog.gaming)
https://www.instagram.com/unpog.gaming/
-------------------------------
Have you found the problem where even if you make changes in external javascript file, and try to refresh the page, the older output remains there.
Of course you can force-refresh it or rename the javascript file, or delete cookies, but all of them don’t sound right or are time consuming.
So I have a simple solution for this.
In this example, I am demonstrating using the ANGULAR JS. But for other JS framework or for basic js implementation, the solution also works.
Here, the external JS file calls the data from JSON file and displays it on browser.
I am making changes in JSON file.
But as you can see, the change is not reflecting even after refreshing.
So to solve that, first go to the place where you linked that Javascript file.
Just add any random REQUEST variable after the filename by adding question mark.
And when you refresh the page, new changes will be reflected.
Next time, if the JS is not reflecting after deploy, just change the version number as shown on the screen.
Thanks for watching. Like share and subscribe.