Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
It’s just not best practice. When you have the time, you should extract this change into a Child Theme.
Hey , thanks for reply
But what about deleting browser history , isnt there any alternative to this.
Every time I add any code , I have to delete history to make it work.
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
This is a browser issue and you can probably find browser addons that clear your cache for you
Browser issue? this happens in every browser . But how is it practical?
After making website live , if i add any javascript it wont work for users untill they delete history if they have visited my site earlier.
thanks.
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
You can add a parameter on the end of your JS file and change it so that the browser doesn’t cache it.
For example:
http://example.com/wp-content/themes/js/myjsfile?1
The parameter is this bit:
?1
Change the number if you release something to users.
Hey , not working for me . What i did
1 ) Default location http://example.com/wp-content/virtue/js/main.js
2 ) Changed the file name to main?1.js
3 ) Opened the site , then added the new code
4 ) Changed the name to main?2.js
but still not working without deleting history . Have i done anything wrong?
Thanks
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Try:
jQuery(".headerclass").click(function(){
alert("hello");
});
still not working without deleting history
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Maybe try using this:
?v=1
Instead of:
?1
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
To make sure it’s not browser specific, does the issue persist in another browser?
Yes , I have tested Opera , Chrome & Firefox