I am trying to do this:
<script src="js/pcehahue.js?v=1.0.1" dmx-bind:src="'js/pchahue.js?v='+version.value"></script>
But seems to not work. I want that if I change the JS file functions dont need to clear cache on browser. Any help.??
I am trying to do this:
<script src="js/pcehahue.js?v=1.0.1" dmx-bind:src="'js/pchahue.js?v='+version.value"></script>
But seems to not work. I want that if I change the JS file functions dont need to clear cache on browser. Any help.??
Do you understand why it doesn’t work? It doesn’t work because dmx-bind:src is set after dmxAppConnect JS is loaded, so it’s already too late
Ideally, you’d need to use server-side rendering. The next question becomes, are you using PHP, NodeJS or something else?
PHP server model.
Any help???
(I can’t help because I’m not familiar with Wappler PHP)
I think “easiest” would be to manually change the HTML tag, to increment the version
Try the following.
At the top of your document, before the <head> section, place the following script
<?php
function autoVersion($file) {
return $file . '?v=' . (file_exists($file) ? filemtime($file) : time());
}
?>
Then for the JS file
<script src="<?php echo autoVersion('js/pchahue.js'); ?>"></script>
The same goes for the CSS file as in
<link rel="stylesheet" href="<?php echo autoVersion('css/styles.css'); ?>" />
With a bit of luck, this will perform the versioning automatically.