SAAS Platform News BooStore.pro CMS
Updates on the platform for creating sites and online stores BooStore.pro

BooStore.pro improves script loading: moving away from $.getScript

BooStore.pro improves script loading: moving away from $.getScript

The BooStore.pro team has optimized JavaScript performance on the platform by replacing $.getScript with dynamic creation of <script> elements using plain JavaScript.







Previously, scripts were loaded like this:

Code: JavaScript
$(function(){
if ($(".hotengine-shop-products-add-count-spinner").length){
         if(typeof $hotengine_shop_product_count_spinner == "undefined"){
		        $.getScript("/templates/scripts/hotengine-script-shop-product-count-spinner.js?v33").fail(function(jqxhr, settings, exception) { console.error("Failed to load script: ", exception);
                });
		 }
} 
});

Now, a different approach is used:

Code: JavaScript
$(function(){
    if ($(".hotengine-shop-products-add-count-spinner").length){
        if (typeof $hotengine_shop_product_count_spinner == "undefined"){
            const s = document.createElement("script");
            s.async = true;
            s.src = "/templates/scripts/hotengine-script-shop-product-count-spinner.js?v34";
            s.onerror = (e) => { console.error(`Failed to load script: ${s.src}`, e); };
            document.head.appendChild(s);
        }
    }
});


Why this is recommended:

  • No jQuery required, fewer dependencies.
  • Control over duplicate loading: script is inserted only once.
  • Asynchronous loading improves performance without blocking the page.
  • Simple and predictable error handling via onerror.
  • Code is more modern and compatible with plain JavaScript.

Added the Cookie Consent and Data Transfer Function to Google Analytics and Tag Manager.
Added delivery status check for orders with the specified TTN Nova Poshta.
Updated Group Editor.