Setting up CSS and JS compression on 1C-Bitrix

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

CSS and JS Compression Configuration for 1C-Bitrix

Without compression, the CSS and JS files of a Bitrix project are delivered to the client at their original size. For a typical project this totals 500 KB–2 MB. Gzip or Brotli compression reduces the volume of transferred data by a factor of 3–7 for text resources — making it one of the easiest performance wins to implement.

Bitrix Built-in Compression Tools

Bitrix includes its own minification and bundling mechanism for CSS/JS, accessible at Settings → Performance → Compression. It operates at the PHP level: it collects files registered via CMain::AddCSSLink() and CMain::AddHeadScript(), minifies them, and stores the results in /bitrix/cache/css/ and /bitrix/cache/js/. The resulting files have a hash in their filename — browsers cache them aggressively.

Important: Bitrix minification only processes files registered through the Bitrix API. CSS and JS included directly in templates via <link> and <script> tags are not processed. On legacy projects, it is common for half the files to bypass the API entirely.

Compression at the nginx Level

Minification reduces file size, but transfer-level compression (gzip/Brotli) is a separate concern. nginx configuration:

gzip on;
gzip_types text/css application/javascript application/json text/javascript;
gzip_min_length 1024;
gzip_comp_level 5;
gzip_vary on;

gzip_comp_level 5 is a balance between compression ratio and CPU load. Levels 6–9 yield minimal additional compression with significantly higher CPU usage. gzip_vary on adds the Vary: Accept-Encoding header, which is required for correct behavior with caching proxies and CDNs.

What to Check During Setup

A common mistake: gzip is enabled in nginx, but PHP-FPM or Bitrix itself also compresses the response — resulting in double compression. The symptom is a browser decoding error or a file downloading instead of executing. Verify with curl -I -H "Accept-Encoding: gzip" https://mysite.com/bitrix/cache/css/file.css — the response headers must include Content-Encoding: gzip.

For minified files with a hash in the filename, configure static (pre-compressed) delivery via gzip_static on — nginx serves a pre-compressed .gz file with no CPU overhead at runtime.

Case Study and Typical Results

A corporate Bitrix "Standard" site with 12 CSS and 23 JS files registered through the API. After enabling Bitrix minification and gzip in nginx: total CSS+JS size dropped from 1.4 MB to 180 KB (after minification) → 48 KB (after gzip). HTTP requests to CSS decreased from 12 to 2, to JS from 23 to 3. Time to DOMContentLoaded dropped by 0.8 s on 3G mobile connections.

Setup takes 4–8 hours: auditing how CSS/JS is included, migrating direct includes to the Bitrix API, enabling minification, configuring gzip in nginx, and verifying the absence of double compression.