Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Feature Request › Conditionally enqueue styles and scripts
Tagged: css js performance
- This topic has 1 reply, 2 voices, and was last updated 5 years, 6 months ago by WCFM Forum.
- AuthorPosts
- May 5, 2019 at 11:37 am #60661janParticipant
Hey,
Not all of my pages, for example the front page or blog pages, are using WCFM/WooCommerce functions. Nevertheless, every page loads a whole bunch of JS and CSS from WCFM that is never used. Actually, even admin related stuff seems to load for non-logged-in-users on the frontend (wcfm_admin_bar_css). This is dragging down the loading times, first contentful paint and speed index of the according pages by more than a second. It also negatively influences the site speed score (SEO relevant).
I went ahead and dequeued all of your styles and scripts for pages that don’t use any WCFM functionality for sure, but I really think it should be part of your plugins to only conditionally enqueue scripts and styles when they are necessary. I don’t want to keep track of every article, site or page template to exclude your JS and CSS from manually and it’s also not a good solution to first enqueue and then dequeue 19 (!!) files:
Styles: ‘wcfm_wc_icon_css’, ‘wcfm_fa_icon_css’, ‘wcfm_admin_bar_css’, ‘wcfm_core_css’, ‘wcfmu_core_css’, ‘wcfmmp_store_list_css’, ‘wcfmmp_store_css’, ‘wcfm-frontend’, ‘wcfm_subscribe_button_css’, ‘wcfm_qtip_css’, ‘wcfm_colorbox_css’, ‘jquery-style’
Scripts: ‘jquery-ui-datepicker’, ‘wcfm_membership_subscribe_js’, ‘wcfm_qtip_js’, ‘jquery-blockui_js’, ‘wcfm_colorbox_js’, ‘wcfm_core_js’, ‘wcfmu_core_js’Please consider this, I think it will have performance benefits for nearly every site using your plugin.
Kind regards and keep it up! 🙂
- May 5, 2019 at 8:39 pm #60775WCFM ForumMember
Hi,
Nevertheless, every page loads a whole bunch of JS and CSS from WCFM that is never used.
– Not at all, it loads only core js and css in all pages. These are require for short code support.
Still we will look into this.
Thank You
- AuthorPosts
- The topic ‘Conditionally enqueue styles and scripts’ is closed to new replies.