Skip to content

Reduced CSS File Size Output for Luma & Blank Theme by Not Compiling Mixins Library into CSS #9507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

laurnts
Copy link

@laurnts laurnts commented May 4, 2017

Updated Description

Magento 2 is using _extends.less to add theme specific mixins which is being called by
@import (reference) 'sources/_extends.less'

However for some reason .abs- prefixed classes went through the compilation mode which end up in the CSS file, bloating the size between 100kb up to 200kb which is particularly alot for just a CSS file. After long investigation this happens because some of the .abs- prefixed mixin is being called within a .media query method which enforces the parsing of a mixin although they are not being used.

Manual testing scenarios

  1. grunt exec:luma && grunt:less luma will compile css file for luma theme
  2. All of the compiled css files are located in pub/static/frontend/...
  3. Here styles-m.css and styles-l.css contains ie: .abs-revert-to-action-secondary
  4. While searching through the entire Magento2 directory, this class .abs-revert-to-action-secondary is never being called directly within the phtml. It's only being called via &:extend(.abs-revert-to-action-secondary).
  5. Replace the whole [.media.....] with [& when (@media-common = true)] in both Luma & Blank
  6. By not compiling the whole '.abs' classes, saved about 100 - 200kb in css file size.

Contribution checklist

  • [yes] Pull request has a meaningful description of its purpose
  • [yes] All commits are accompanied by meaningful commit messages

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented May 4, 2017

CLA assistant check
All committers have signed the CLA.

@laurnts laurnts changed the title Reduced CSS File Size Output for Both Luma & Blank Theme by Not Compiling Mixins Reduced CSS File Size Output for Both Luma & Blank Theme by Not Compiling Mixins into CSS May 4, 2017
@laurnts laurnts changed the title Reduced CSS File Size Output for Both Luma & Blank Theme by Not Compiling Mixins into CSS Reduced CSS File Size Output for Luma & Blank Theme by Not Compiling Mixins Library into CSS May 4, 2017
@laurnts laurnts closed this May 4, 2017
@laurnts laurnts reopened this May 4, 2017
@okorshenko okorshenko self-assigned this May 16, 2017
@okorshenko okorshenko added this to the May 2017 milestone May 16, 2017
@okorshenko okorshenko modified the milestones: May 2017, June 2017 Jun 1, 2017
@okorshenko
Copy link
Contributor

@laurnts thank you for your contribution. Unfortunately, these fixed break UI on store front.
screen shot 2017-05-18 at 11 14 05

@okorshenko okorshenko closed this Jun 5, 2017
@magento magento locked and limited conversation to collaborators Jun 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants