<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: John</title>
    <description>The latest articles on DEV Community by John (@hypernetware).</description>
    <link>https://dev.to/hypernetware</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3798388%2F9b9f6d81-eba8-41cd-ac9d-c01b2bfe4d11.png</url>
      <title>DEV Community: John</title>
      <link>https://dev.to/hypernetware</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hypernetware"/>
    <language>en</language>
    <item>
      <title>Easily Minify Your CSS and JS in Symfony with SensioLabs Minify Bundle</title>
      <dc:creator>John</dc:creator>
      <pubDate>Sat, 28 Feb 2026 17:46:45 +0000</pubDate>
      <link>https://dev.to/hypernetware/easily-minify-your-css-and-js-in-symfony-with-sensiolabs-minify-bundle-50hf</link>
      <guid>https://dev.to/hypernetware/easily-minify-your-css-and-js-in-symfony-with-sensiolabs-minify-bundle-50hf</guid>
      <description>&lt;p&gt;Page load speed directly affects your bottom line. According to &lt;a href="https://www.retailtouchpoint.com/topics/customer-experience/how-poor-page-load-time-is-killing-your-business" rel="noopener noreferrer"&gt;RetailTouchPoints&lt;/a&gt;, a single second of delay reduces conversions by 7% and drops customer satisfaction by 16%.&lt;/p&gt;

&lt;p&gt;Honestly, I always felt like having a slow website caused more damage than that. Anyway, no one wants a slow site. Fast websites feel better. &lt;/p&gt;

&lt;p&gt;If your site is slow, minifying your CSS and JavaScript is an easy win. Minification strips out unnecessary whitespace and comments, reducing file size without changing functionality. &lt;/p&gt;

&lt;p&gt;The easiest way I have found to minify css and javascript in Symfony is the &lt;a href="https://github.com/sensiolabs/minify-bundle" rel="noopener noreferrer"&gt;Sensio Labs Minify Bundle&lt;/a&gt;. This bundle makes it so incredibly easy to minify your javascript and css that it's virtually no effort on your part. &lt;/p&gt;

&lt;p&gt;To use MinifyBundle you will need be using Symfony AssetMapper. To install Minify Bundle run this: &lt;code&gt;composer require sensiolabs/minify-bundle&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After you install it, MinifyBundle works by downloading a binary and minifying your js and css. Its very simple. When you run &lt;code&gt;php bin/console asset-map:compile&lt;/code&gt; minify bundle will now automatically minify your css and js. &lt;/p&gt;

&lt;p&gt;However, I do have one caveat. The docs say that the minified js and css will only be served in prod mode,(after you run assetmap:compile) but that wasn't my experience. You will probably want unminfied css and js during dev mode so you can read it. Here is how I got unminified css/js in DEV mode, but minfied in PROD mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sensiolabs_minify:
    asset_mapper:
        # Exclude already minified assets
        ignore_paths:
            - '*.min.js'
            - '*.min.css'
    minify:
        # Use local binary if available
        # binary_path: 'auto'

        # Specify local binary path
        # binary_path: '/usr/bin/minify'

        # Download binary from GitHub
        download_binary: true

when@test:
    sensiolabs_minify:
        asset_mapper:
            enabled: false
when@dev:
    sensiolabs_minify:
        asset_mapper:
            enabled: false

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm on Symfony 8.0.6, so I'm sure in future versions, the recipe will install it as expected, and js and css won't be minfied in dev mode. Please remember to get it to work in PROD mode, you have to run assetmap:compile first. &lt;/p&gt;

&lt;p&gt;Thanks,&lt;br&gt;
John&lt;/p&gt;

</description>
      <category>symfony</category>
      <category>css</category>
      <category>javascript</category>
      <category>minify</category>
    </item>
  </channel>
</rss>
