Introducing ReUI:Open-source UI components and apps built with React, Next.js and Tailwind CSS
Browse ReUI

How to Reduce CSS/JS Bundle Size By Removing Unused Resources Using Gulp


Hi,Metronic's by default includes all its available resources within the gulp config so the bundle size of the compiled CSS/JS files. To reduce the file size of the CSS/JS bundle files follow the below steps:

  1. Open theme/tools/gulp.config.js and refer to base->global->src config node. The mandatory contains of the core resource that are required for the Metronic's base functionalty while the optional node lists the optional resource that can be excluded according to a project requirements.
  2. Under optional node remove any resource by referring to a plugins documentation
  3. Recompile the assets using the Gulp builder
Regards.
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (19)


Dino Game Thanks for your shareing

The services offered from Jodhpur call girls service are so appealing that you'll be somewhat insane when you learn about the services. These services were created by the escorts themselves the manner that they provide only pleasure and have no negative results. What you can't get from normal escorts. From a security perspective there is no need to take any action since all necessary actions are performed by the ladies themselves.



We are very aware of what you require as a visitor. We do our best to provide you with your dream girls. We have stunning Udaipur call girls that will act as your companions while you are in Udaipur. We guarantee that you will experience the most romantic every day in love with us and with our incredible service.



Nainital is the entry point to India. Every new service, culture and product enters India via it. This is the best spot to test new products and services to see if it is a good fit of it within India. Additionally, this most prestigious city in India offers a wide range of innovative products and provides many new services and activities that span the world.
Nainital call girls



Now, I am one of the most sought-after Dehradun call girls. I would like to end my career on my own and take off into the clouds to reach my ultimate goal. I am five feet six" inches high (in my naked feet) with the physical measurements of 36DD/28/38.



If you're looking for a top-notch creative play app, toca boca mod apk (unlocked all) 2024 is a must-try. It provides fantastic features that elevate your gaming experience.



"For anyone looking to create professional-quality videos, inshot pro APK is the perfect tool. Download the latest version and unlock all the advanced features for free!"



"Discover the world of free music streaming with blackholesapk! Visit our website for a fast and secure download. Enjoy ad-free music in high-quality audio, with offline capabilities. The Blackhole APK is the perfect choice for music lovers who want it all for free!"



Workforce management software streamlines scheduling, attendance, and productivity for businesses. Workforce management solutions enhance efficiency in various sectors, ensuring optimal resource allocation. Contact center workforce management and call center workforce management software specifically cater to the unique demands of customer service environments, optimizing agent performance and customer satisfaction.



To reduce the size of Metronic's compiled CSS/JS files, open `theme/tools/gulp.config.js`, and in the `base->global->src` configuration, remove unnecessary resources under the `optional` node (based on project requirements). Then, run the `gulp` command to recompile the assets, generating smaller files.Block Blast



Hi Sean, thanks for this guide! Can I apply these steps to optimize the CSS/JS bundle size for my photo editing website? Are there any specific tips for such platforms?
here is my website: meituapksite.com



In angular how can I reduce that CSS/JS Bundle?



Hi,

For Angular, you can configure the used in src/assets/sass/core/vendors/plugins/_plugins.scss.

Regards.



What about the ones located in buld->plugins->custom like draggable, prismjs, datatables, leaflet, etc? Can they be removed too?



Hi,

Yes, you can exclude it from your build if you don't use them. Or at least just do not include in your HTML the assets of those plugins.

Regards.



FYI, in v8.2.2, optional is located under:
build->plugins->global->src->optional



Hi,

bundle.css & bundle.js files remain the same size even if i deleted optional nodes.

Shouldn't these files be reduced in size?

https://prnt.sc/-QMb4VcRxMB3



I got same concern that files are really big, especially those two. I think downloading over 2MB or even 3MB it's not very optimal, so i decided to do sth with it.
I spend some time looking for some optimizations and finally found purgecss.
It's not like just plug and play and you need to experiment a little bit what should be removed and what should be kept, knowing that Metronic is really JS oriented and lots of things are happening with some clicks etc, so it also impacts CSS.
At the end I managed to reduce file size to around 200KB (yes, I don't use all that stuff in Metronic, but page is still nice, responsive and looks pretty).



It is not reducing the size.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(