Preventing Script Optimization
By default StoreFronts will take the external scripts on the page or included and unify them into a few .js files that are injected into the page near the close body tag. The reason for this is:
-
Reduce the number of requests
-
Delay the execution of scripts to increase the load time of pages
-
Push the JS files to the CDN for faster delivery to the customer’s browser.
By default inline script tags on the page will be pushed down to the end of the page. If you have a script you do not want moved, add data-uc-ignore="true" to the tag and UltraCart will leave it alone. The attribute works on external <script src="..."> tags as well as inline scripts, and excludes the script from unification and CDN offload entirely, so an exempted script no longer benefits from CDN edge caching or request consolidation.
<script type="text/javascript" data-uc-ignore="true">
// Your script here.
</script>