exponentcms / exponent-cms

Content Management, Simple.
exponentcms.org
GNU General Public License v2.0
59 stars 24 forks source link

YUI 3 CSS styles unnecessarily included twice #1511

Closed exponentcms closed 4 years ago

exponentcms commented 4 years ago

If you profile the files that are loaded, you will notice that the styles for any module that references a YUI 3 widget are included twice. The first time is loaded statically via the <link> tag in <head> (minified and stitched to the others) and the second time it is loaded dynamically via YUI's built-in Loader infrastructure. See reference:

http://yuilibrary.com/yui/docs/tutorials/skins/#loading-skin-files

Given that it is being loaded dynamically, it is safe to remove the {css} tags from tpl files that are referencing YUI3 css files. For example in /framework/modules/text/views/text/showall_tabview.tpl it is safe to remove the following:

{css unique="id" link="$smarty.const.YUI3_PATHtabview/assets/skins/sam/tabview.css"}

{/css}

And you will notice that the tabview styles are still maintained. This applies to all other tpl files that reference YUI3 css files. This will minimize the amount of css that is downloaded, and applied duplicately hopefully improving performance. YUI's loader class is commented as such:

/**

exponentcms commented 4 years ago

This is not true when the files are minified. This bug can be closed.

Thanks

exponentcms commented 4 years ago

Lighthouse URL: https://exponentcms.lighthouseapp.com/projects/61783/tickets/344