Get Pro

Overview

Magical Shop Builder includes a comprehensive performance system (class-mpd-performance.php, 673 lines) that optimizes asset loading and rendering. All optimizations are configurable through the Settings panel.

The performance module provides:

CSS Minification

When enabled, the plugin automatically minifies its CSS files and caches the results for optimal delivery.

Cache is automatically invalidated on:

Cache directory structure
wp-content/
  uploads/
    mpd-cache/
      mpd-display-style.min.css
      mpd-ajax-search.min.css
      bootstrap-custom.min.css
      ...

JavaScript Minification

JavaScript minification uses the same file-based caching approach as CSS minification.

Both CSS and JS minification only target Magical Shop Builder assets. Third-party plugins, themes, and WordPress core files are never modified.

JavaScript Deferring

When enabled, the plugin adds the defer attribute to its script tags, allowing them to load asynchronously without blocking page render.

Before vs After
<!-- Without deferring -->
<script src="mpd-global-widgets.js"></script>

<!-- With deferring enabled -->
<script src="mpd-global-widgets.js" defer></script>

Template Caching

Template caching stores the rendered HTML output of Magical Shop Builder templates, eliminating repeated PHP processing and database queries on subsequent page loads.

Cache is automatically invalidated when:

Lazy Loading

Lazy loading defers the loading of off-screen content until the user scrolls near it, reducing initial page weight and improving load times.

Preloader System

The preloader system (class-mpd-preloader.php, 652 lines) provides a smooth loading experience and prevents Flash of Unstyled Content (FOUC). It has two modes depending on whether it is enabled or disabled in settings.

When Enabled

A full preloader overlay is displayed while the page loads:

When Disabled (FOUC Prevention)

Even when the preloader is disabled, a lightweight FOUC prevention mechanism is active:

FOUC prevention (injected automatically)
<style>body { opacity: 0; transition: opacity 0.3s ease; }</style>
<script>
window.addEventListener('load', function() {
    document.body.style.opacity = '1';
});
// Safety fallback
setTimeout(function() {
    document.body.style.opacity = '1';
}, 4000);
</script>

Asset Management

The plugin uses intelligent asset loading (assets-managment.php, 292 lines) to register and enqueue only the CSS and JavaScript files needed for each page. Assets are conditionally loaded based on which widgets and features are active.

Registered CSS Handles

Category Handles
Framework bootstrap-custom, bootstrap-grid, swiper
Widget Styles mgproducts-hover-card, mgproducts-tab, mgproducts-pricing, mgproducts-accordion
Feature Styles mpd-ajax-search, mpd-advanced-filter, mpd-header-wishlist-compare
Page-Specific mpd-single-product, mpd-cart-widgets, mpd-checkout-widgets, mpd-multi-step-checkout, mpd-express-checkout, mpd-my-account-widgets, mpd-shop-archive-widgets, mpd-global-widgets, mpd-thankyou-widgets
Main (always loaded) mgproducts-style

Registered JS Handles

Category Handles
Framework bootstrap-bundle, swiper / mg-swiper
Core Scripts mgproducts-script, mgproducts-main
Widget-Specific mgproducts-slider, mgproducts-carousel, mgproducts-tcarousel
Feature Scripts mpd-ajax-search, mpd-products-tab-ajax, mpd-global-widgets, mpd-shop-archive, mpd-advanced-filter
WooCommerce Scripts mpd-add-to-cart, mpd-cart-table, mpd-mini-cart, mpd-cross-sells, mpd-coupon-form, mpd-checkout-widgets, mpd-multi-step-checkout

Widget Enable/Disable

Disabling unused widgets is one of the most effective ways to reduce page weight. Each disabled widget saves both its CSS and JS payload from being loaded.

Recommended: Disable all widgets you’re not using. This is the simplest way to reduce the plugin’s footprint on pages where specific widgets aren’t needed.

Best Practices

Follow these recommendations to get the best performance from Magical Shop Builder:

  1. Enable CSS and JS minification on production sites to reduce file sizes
  2. Enable JS deferring for non-critical scripts to avoid render-blocking
  3. Enable template caching to avoid repeated PHP processing
  4. Disable unused widgets in the Widgets tab to eliminate unnecessary asset loading
  5. Enable lazy loading for product images to speed up initial page load
  6. Use the preloader on pages with heavy content for a smoother user experience
  7. Test with PageSpeed Insights after enabling optimizations to measure improvements

Performance settings in Magical Shop Builder complement server-side optimizations. For best results, combine with a good hosting environment, CDN, and object caching.

If you experience layout issues after enabling minification, try clearing the cache at wp-content/uploads/mpd-cache/ or disable the specific minification setting.