We had to roll back the update related to optimizing assets loading released in Getwid version 1.5.3 for the following reasons:
- So far there is no 100% accurate method to identify that the block that requires assets is displayed on the page. You can find more examples and case studies on this forum.
- The optimization might not work properly in case a block is a reusable one since the content of a reusable block is within another post.
- There is no evidence that block-based themes can properly handle this optimization; to wit, when blocks are used in the header, footer, or widget zones.
- If there is a block that displays any posts on a page, we can’t effectively recognize the content of these posts until they are painted on a page.
One more limitation that holds us back from this optimization is that CSS styles of the blocks are loaded before style.css of your theme to ensure the blocks can blend with the theme styles.
However, in Getwid version 1.5.4 we managed to minimize the total size of the loaded assets compared to the previous plugin versions. Don’t forget that you can disable unneeded Getwid blocks to improve the performance.
An empty page contains 6 assets, 210 kB in total (which is twice as less than in the previous version). You as a developer can also control how many assets to load by enabling/disabling individual or all assets in each particular case.
Follow this link below to examine the example we’ve created for you
https://gist.github.com/mototeam/34b4ef0cb4f4ff4ff4d3c8a5f9a5cafe