Fragment CSS for each Elementor element so only the necessary CSS is loaded. #27270
Nazrinn
started this conversation in
Feature Request
Replies: 1 comment 4 replies
-
+1000 I use Debloat's Remove Unused CSS feature, but the way you've described it sounds much more efficient and would result in further improved load times. Debloat already makes a massive difference, so if this was implemented natively that would be fantastic. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Prerequisites
What problem is your feature request going to solve? Please describe..
Hello there!
When it comes to optimisation, it's no secret that Elementor could use a little push. Something I'm very surprsed about and that Elementor doesn't seem to do is dynamic CSS loading (similar to how JS framework do it).
The Problem
Currently, Elementor loads all possible styles in the front-end bulk. For instance:
/wp-content/uploads/elementor/css/global.css
,/wp-content/plugins/elementor/assets/css/frontend.css
and/wp-content/plugins/elementor-pro/assets/css/frontend.css
contain styles for elements that might not be even used to the website, such as icon lists, video widgets, dividers, lightboxes, so on and so forth. Elementor Pro'sfrontend.css
even contains styles for WooCommerce, which is not installed on most WordPress websites.The presence of those extra styles significantly impact page load and rendering times, and really shouldn't be loaded at all if they are not necessary. Additionally, given HTTP2 (and above), loafing 1 big file for all styles is not great when loading multiple smaller files might be quicker.
Due to Elementor's nature, some of those bulk styles might also be render-blocking, forcing you to load the whole style file before being able to display the page, worsening FCP times.
Although yes, most big caching plugin can attempt to remove unused CSS, it often results in removing essential styles for elements triggered via interractions, such as lightboxes; redering this solution non-viable.
Describe the solution you'd like.
The solution
Breaking it down:
/element/customcode.css
, Icon Box elements has its style loaded in/element/iconbox.css
, so on and so forth. This will allow:/element/customcode.php
would containwp_enqueue_style
for/element/customcode.css
. No element manager needed!This is something I do on my own locally developped themes (using Webpack and all that jazz). I'm sure that's something Elementor can pull off.
Describe alternatives you've considered.
Using caching plugin by setting up critical CSS, removing unused CSS using a caching plugin, disabling Elementor styles, making my own elements (modules) using Elementor's saved block function combined with a shortcode that load my element's CSS.
Additional context
Reference Lighthouse CSS performance on a very very barebone Elementor website that only contains a Svelte App on the homepage (no caching):
Full Lighthouse report (PDF).
Agreement
Beta Was this translation helpful? Give feedback.
All reactions