Magento fatal error cannot redeclare function theme Blanco

Magento fatal error cannot redeclare function theme Blanco

August 30, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento fatal error cannot redeclare function theme Blanco

Optimizing your Magento theme for better performance is essential for maintaining customer satisfaction. One key aspect of this optimization lies in handling CSS efficiently. In this post, we’ll dive into the best practices for minimizing and compressing your CSS files to enhance the speed of your e-commerce store.

Understanding CSS Minification

CSS minification involves removing unnecessary whitespace characters (spaces, newlines, and comments), as well as shorting property names and values without changing their functionality. This process reduces file size significantly, leading to faster loading times for users.

Automating CSS Minification in Magento 2

Magento 2 provides built-in support for CSS minification through the use of the Less preprocessor. To enable this feature:

  1. Navigate to Stores > Configuration > Sales > General.
  2. Set the “JavaScript Settings” and “CSS Settings” fields to “Minify.”

By default, Magento 2 uses the LESS preprocessor to handle minification for both JavaScript and CSS files. It automatically compresses and combines multiple CSS files into a single, minimized file during compilation.

Customizing CSS Minification

While Magento’s built-in minification is sufficient in most cases, you may want to customize it further for specific themes or extensions. To do this, you can leverage the view.less file located in your theme directory (usually under app/design/frontend/Vendor/ThemeName/web/css/source).

In this file, you can define your custom CSS rules and variables that will be applied during compilation. For example:

/* Theme-specific styles go here */
body {
    background-color: #f0f0f0;
}

.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Open Sans', sans-serif;
}

Remember to include your custom styles within a //@theme-namespace comment block to ensure they are included during the merge process.

Enabling CSS Compression

In addition to minification, you can further optimize your CSS by enabling compression. This involves removing unnecessary whitespace and shortening property names using tools like Clean-CSS or UglifyCSS.

To enable CSS compression:

  1. Install a CSS compression tool of your choice (e.g., Clean-CSS).
  2. Configure your Magento 2 store to use the compression tool during file generation.
  3. Set up a cron job to run the compression script periodically or manually trigger it as needed.

Conclusion

Optimizing CSS files is crucial for maintaining fast and responsive e-commerce stores in Magento 2. By leveraging Magento’s built-in minification features and customizing your theme-specific styles, you can achieve significant performance improvements.

Don’t forget that optimization goes beyond just CSS – ensuring proper image optimization, enabling caching mechanisms like Varnish or Redis, and keeping your Magento version up-to-date are all essential factors in maintaining a high-performing online store.

Magento 2 Performance Extensions Themes

Our network