SAAS Platform News HotList.biz CMS
Updates on the platform for creating sites and online stores HotList.biz

Hotlst.biz improves script loading: moving away from $.getScript

Hotlst.biz improves script loading: moving away from $.getScript

The Hotlst.biz 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 header for block with bundle.
Added option to display products of child categories.
Added the ability to enable email notification about automatic import or update.