Frontend CSS file improvements
-
Right now you’re using the same CSS file for editor and frontend. This results in the following classes always being unused CSS because they’re only needed for editor:
.o-animations-control__popover:not(.is-mobile).is-bottom{z-index:9999999}.o-animations-control__popover .components-popover__content{overflow-y:hidden}.o-animations-control__popover .components-menu-group{padding:7px}.o-animations-control__popover .components-popover__items{max-height:300px;overflow-y:auto}.o-animations-control__popover .components-popover__items button.is-selected{background:#f8f9f9}.o-animations-control__popover .components-popover__items button i{margin-right:5px}.o-animations-control__popover .components-popover__items .o-animations-control__category{font-weight:700}.o-animations-control .components-dropdown{display:flex}.o-animations-control .o-animations-control__button{background:transparent;border:1px solid #8d96a0;border-radius:4px;box-shadow:0 0 0 transparent;height:auto;line-height:28px;padding:0 12px 2px;position:relative;transition:box-shadow .1s linear;width:100%}.o-animations-control .o-animations-control__button.is-button{background:transparent}.o-animations-control .o-animations-control__button:hover{background:#fafafa;border-color:#999;box-shadow:inset 0 -1px 0 #999;color:#23282d;text-decoration:none}.o-animations-control .o-animations-control__button:focus{border:1px solid #000}.o-animations-control .o-animations-control__button:after{border-left:3px solid transparent;border-right:3px solid transparent;border-top:5px solid;content:"";display:block;height:0;margin-left:4px;margin-right:2px;pointer-events:none;position:absolute;right:8px;top:12px;width:0}.otter-animations-count-image{width:100%}@media screen{.hidden-animated{visibility:hidden}}@media(max-width:782px){.o-animations-control .o-animations-control__button{padding:5px 24px 5px 8px}.o-animations-control .o-animations-control__button:after{top:16px}}.o-anim-typing-caret:after{-webkit-animation:blink 1s step-end infinite;animation:blink 1s step-end infinite;color:#2e3d48;content:"|";font-weight:100}@-webkit-keyframes blink{0%,to{color:transparent}50%{color:#000}}@keyframes blink{0%,to{color:transparent}50%{color:#000}}.o-control-panel-control{padding:10px 0}.o-control-panel-control .components-base-control__title{align-items:center;display:flex;justify-content:space-between}.o-control-panel-control .components-base-control__title label{padding:5px 0}.o-control-panel-control .components-base-control__title .floating-controls .components-dropdown{display:flex}.o-control-panel-control .components-base-control__title .floating-controls .components-dropdown button.is-tertiary{border:none;box-shadow:none;color:#1e1e1e}.o-control-panel-control .components-base-control__title .floating-controls .components-dropdown button.is-active,.o-control-panel-control .components-base-control__title .floating-controls .components-dropdown button.is-tertiary:hover{color:var(--wp-admin-theme-color)}.o-control-panel-control .components-base-control__title .floating-controls .components-dropdown button .dashicon{margin:2px}.otter-popover-settings{min-width:300px;overflow:hidden;padding:10px}.otter-popover-settings .components-button-group{padding-bottom:10px}Could you please separate editor styles from animation styles and don’t load them on frontend?
Additionally there is a matter of loading 73KB CSS file even though most users won’t need every animation available. I saw your comment in another thread where you said that having CSS file for every animation could negatively impact PageSpeed Score.
This is a difficult situation. From one point of view, HTTP2 allows to load multiple files at the same time, but then again, having 5 animations on a landing page would result in 6 files (core + 5 animations) and HTTP2 has limits.
Which is why I propose a compromise. Create plugin settings page where users will be able to toggle separate animations on and off. After they press “Save settings” the plugin generates CSS file that only contains core + enabled animations. This file is then enqueued whenever animations are used. That way we reduce overall CSS size without enqueueing tons of small files.And the third part is directive
-webkit-keyframes. Can we have an option to turn it off? It’s only used with old browsers Chrome <= 42, Safari <= 8.4, Opera <= 29. It basically doubles CSS size.
The topic ‘Frontend CSS file improvements’ is closed to new replies.