I have a results page with a button that once pressed redirects to a destination page. On the results page I also have a function that clicks 5 hidden HTMX buttons which activate a Django function that loads flight prices.
I find that the when I click the redirect button, instead of automatically loading the destination page, it waits for the 5 hidden flight prices buttons to be clicked first. This is causing the destination page to load very slowly. I tested this by removing the function that clicks the 5 hidden buttons and noticed that the destination page loaded very quickly. How can I have the destination page load without waiting for the 5 hidden buttons on the results page to be clicked?
javascript
<!-- get flight prices script -->
<script type="text/javascript">
async function auto_button_click() {
// if mobile
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
// click htmx button
document.getElementById("price_button7").click();
document.getElementById("price_button8").click();
document.getElementById("price_button9").click();
document.getElementById("price_button10").click();
document.getElementById("price_button11").click();
document.getElementById("price_button12").click();
}
// if desktop
else {
// click htmx button
document.getElementById("price_button1").click();
document.getElementById("price_button2").click();
document.getElementById("price_button3").click();
document.getElementById("price_button4").click();
document.getElementById("price_button5").click();
document.getElementById("price_button6").click();
}
}
</script>