BooStore CMS Platform News
Updates on the BooStore platform for creating websites and online stores

BooStore improves loading: moving away from $.get

BooStore improves script loading: moving away from $.getScript

The BooStore 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 translation of tabs in the de ion of product cards.Added HTML widget with comments/reviews.Added an additional function for selecting a payment method on the checkout page.