I run an eCommerce website. On our order confirmation page we run a third-party javascript that automatically executes an optional survey.
The problem with the survey is that it takes twenty seconds to execute and slows down the rendering of the crucial 'Order Complete' page.
I am wanting to prevent loading of this script until the customer clicks a button.
Ideally, the page will load without executing the script. There will be some text on the page that says, "Would you like to take a survey? If yes, click here." Then the page will call the third-party javascript to execute the survey code.
Below is the third-party javascript. The first script tag just collects variables, and the second script tag actually runs the survey code.
<script language="JavaScript">
// var passin_x =; //comment out to default center or adjust horizontal position by pixel
// var passin_y =; //comment out to default center or adjust vertical position by pixel
var orderId='@@order_id@@';
// var z_index =; //default 9995
var cartTotal='@@purchase_total@@';
// var billingZipCode=;
// Pass up to 5 products from customer shopping cart
//var productsPurchased= 'URL=^SKU=^GTIN=^PRICE=|URL=^SKU=^GTIN=^PRICE=|URL=^SKU=^GTIN=^PRICE=|URL=^SKU=^GTIN=^PRICE=|URL=^SKU=^GTIN=^PRICE=';
</script>
<script type="text/javascript" src="https://eval.bizrate.com/js/pos_xxxxx.js">
</script>
How can I dynamically load the script after the click event?