Dear @Antoine-dvc
As a first test wrap the code into a 'newpage event" within your Custom <head> Content:
https://laytheme.com/documentation/custom-javascript.html
<script>
window.laytheme.on("newpageshown", function(){
// insert your desired code here
});
</script>
Best
Richard