Home › Forums › Pro Support › Is Specific WPSP CSS Applied Sitewide?
Tagged: css
- This topic has 7 replies, 2 voices, and was last updated 4 years, 1 month ago by
Tom.
-
AuthorPosts
-
October 13, 2019 at 3:57 pm #11469
Jake
ParticipantHi Tom,
Absolutely love the plugin.
I was wondering: Does the CSS styles applied to one WPSP apply across the site (i.e. added to a sitewide stylesheet)?
For example, if I style a particular WPSP on a single page (using your inbuilt plugin styling, not my own added CSS) in a certain way, will the CSS that applies to that WPSP be carried across my entire site, or only on the pages where this particular WPSP is present?
Thank you for your clarification! Love your work.
October 16, 2019 at 11:13 am #11500Tom
KeymasterHi there,
If you use the ID in your CSS, it will only apply to that one list.
For example, every list has a parent
section
element, which has a unique ID like this:wpsp-123
123 is the ID of the list.
So your CSS would look like this:
#wpsp-123 h2 { }
Let me know if you need more info š
October 16, 2019 at 3:39 pm #11510Jake
ParticipantSorry for my poorly worded question Tom, that’s not quite what I meant.
Rather, is there some WPSP CSS code baked into the plugin that is specific to each WPSP, but is being shown site-wide?
e.g. there will be this code:
#wpsp-123 h2 { }
Shown on all page. This CSS code is specific to WPSP with ID 123, but is still being shown on the page even if this particular WPSP is not present on a particular page (but another WPSP is).
Coming at it from a performance standpoint š
October 21, 2019 at 5:55 pm #11587Tom
KeymasterThere is a CSS file being loaded for the lists on all pages, unfortunately. WordPress doesn’t provide a way to add styles only when a shortcode is present on the page. Loading javascript is different, as we can check the content before adding it to the footer. Since styles are loaded before the content, there is no way to check unless we load them in the footer.
There are some plugins out there that should help, though: https://wordpress.org/plugins/wp-asset-clean-up/
Hope this helps š
October 21, 2019 at 9:30 pm #11594Jake
ParticipantHi Tom,
As a user of GP Premium, I can see just how much effort you put into performance ā so I had no doubt you were following best performance practices.
That said I didn’t realize there wasn’t even an *option* for this kind of functionality. No wonder so many plugins have this issue.
Just one more question to add to this then: does that mean that I should delete and/or draft any of the WPSP that I’m no longer using?
Otherwise wouldn’t that mean that their specific CSS associated with them, e.g.:
e.g. there will be this code:
#wpsp-123 h2 { }
Would be on all of my wordpress pages ā even though the shortcode isn’t used? Since you can’t see if the WPSP is being used, I would presume that you publish the CSS based on its published/draft status?
I realize this is a tiny amount of CSS, but if it’s WPSP that I’m no longer using then there is no point keeping them around if it’s adding even a tiny amount of CSS.
Please let me know whether I can draft these posts to remove the CSS associated with them, or whether I need to delete the specific WPSP altogether.
Thank you very much for your help Tom!
October 22, 2019 at 7:53 pm #11603Tom
Keymasterdoes that mean that I should delete and/or draft any of the WPSP that Iām no longer using?
The stylesheet will only load once, regardless of how many WPSP lists you have on your website. Where possible, we load CSS specific to each list directly above the list in the HTML. This makes it so less CSS is added site-wide.
As for your custom CSS, you can use a plugin like “Simple CSS” to add it only on specific pages. That way your CSS isn’t loading where it doesn’t need to.
Let me know if that makes sense or not š
October 22, 2019 at 9:14 pm #11606Jake
ParticipantWhere possible, we load CSS specific to each list directly above the list in the HTML. This makes it so less CSS is added site-wide.
This is what I was asking, to avoid the case where code from a completely unused yet still published WPSP was adding sitewide CSS.
Simple CSS is an excellent plugin and I use it. I hear the inventor is a nice guy!
Thank you very much for your help Tom š
October 24, 2019 at 8:10 pm #11640Tom
KeymasterNo problem! š
-
AuthorPosts
- You must be logged in to reply to this topic.