The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

How can I improve page loading speed in Metronic without breaking JavaScript components?


I’m working on a project using Metronic and I’m trying to improve the page loading speed without affecting the existing JavaScript components.

I’ve already looked at image optimization and caching, but I’m not sure how much I can safely optimize or defer the Metronic JS and CSS files.

Has anyone found a good way to reduce the initial page load while keeping components like menus, modals, forms, and other interactive elements working properly?
this site:


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)

Hi there,

Understanding

You want to improve initial page load in Metronic (v8 Bootstrap or v9 Tailwind) by deferring or trimming JS/CSS, without breaking components like menus, modals, and forms.

Solution

Metronic components auto-initialize from data-kt-* attributes when the core bundle runs, so the golden rule is: keep the core bundles and their load order intact. Deferring those will break component initialization. Safe, high-impact optimizations instead:

  1. Defer only third-party scripts — analytics, tag managers, and non-Metronic libraries can use defer or load after the page. These do not affect Metronic components.
  2. Remove plugins you do not use — each demo loads vendor bundles (e.g. ApexCharts). If a page has no charts, drop that script and its CSS.
  3. Preload the critical assets — preload the main stylesheet and the core JS bundle so they start downloading immediately:
    <link rel="preload" as="style" href="/assets/css/styles.css">
    <link rel="preload" as="script" href="/assets/js/core.bundle.js">
    
  4. Lazy-load below-the-fold images with native lazy loading: loading="lazy" on <img> tags.
  5. Enable compression and caching — gzip/Brotli on the server plus long cache headers for the bundled assets (they are hashed on rebuild).
  6. In production builds, unused CSS is purged automatically — on Metronic 9 (Tailwind) run a production build so only classes actually used in your markup are shipped. On Metronic 8 (Bootstrap), the compiled style.bundle.css is already a single file, so focus on removing demo-specific SCSS you do not use before rebuilding.

Two important warnings:

  • Do not add defer/async to the Metronic core bundle (core.bundle.js on v9, scripts.bundle.js on v8). The components register and initialize in a specific order; deferring them breaks menus, modals, and form validation.
  • CSS load order matters. Moving or splitting the bundle CSS can break styling (the same applies to vendor themes like PrismJS which must load after the main styles).

For Metronic 9, the Composer also lets you generate leaner page structures from reusable HTML views, which keeps the DOM smaller and speeds up rendering.

Sources

Next Steps

If you can share which version you are using (Metronic 8 or 9) and which demo, I can point you to the exact bundle names and a page-specific trim list. A good first pass is: run Lighthouse, remove the vendor scripts that are not used on that page, and defer the analytics snippet.


This reply was generated by AI. A human will follow up if needed.

Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(