dnafactory/module-critical

A module that allows to serve the critical.css generated by less, directly from the static contents.

Installs: 1 933

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:magento2-module

1.0.3 2022-08-31 09:25 UTC

This package is auto-updated.

Last update: 2024-04-29 04:47:31 UTC


README

License

A module that handles the critical css generation from less sources.

The elephant in the room

If you want to serve critical css as less sources, of course, you can put your critical.less in your custom theme directory.

app/design/frontend/[Vendor]/[Custom-Theme]/web/css/critical.less

And then, in the static:content:deploy phase, the critical.css file will be generated and saved in the static content folder. However, even in production mode, Magento will always try to fetch that file from the source directory, so it will re-build critical.css on each request.

Solution

This module simply replaces Magento's original ViewModel that reads the critical.css content, to fetch it from the static content folder instead.

Happy Coding