latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Remove css and optimize JS

Home Forums Community Forum Remove css and optimize JS

This topic contains 4 replies, has 3 voices. Last updated by  Jason (Lead Developer) 4 years, 9 months ago.

Topic Author Topic
Posted: Monday Mar 26th, 2012 at 2:43 pm #9132

I’m having trouble removing the default css this doesn’t seem to be working for me anymore

<?php
add_action ("ws_plugin__s2member_after_loaded", "remove_s2_pro_css");
function remove_s2_pro_css ()
    {
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
    }
?>

Are there any other hooks or filters I can use?

Also I was wondering if there are any plans to optimize the dynamic javascript by minifying and then zipping it?
Or is there a way to intersept it and do that? Its the only problem I have now in terms of google page speed and Yslow results.
I would like to vote for such a feature.

Keep up the good work on what is a brilliant plugin :)

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Tuesday Mar 27th, 2012 at 1:42 am #9166

Thanks for the kudos, Philly. :)

Jason is working on improving the JS and CSS, for sure. Not sure what approaches he’s taking yet, cause I still haven’t seen the new code, but this is something that we mean to speed up as much as we can.

Sorry, been trying to figure out why it wouldn’t work, but couldn’t solve it yet. I’ll email Jason, will let you know when I know something.

Posted: Tuesday Mar 27th, 2012 at 5:41 am #9192
Staff Member

Thanks for bringing this to my attention.

That hack stopped working with the release of s2Member v120219.

Quick fix: change the name of your hack file, to: s2-o.php

The reason it stopped working is because of s2Member’s /s2member-o.php WordPress loader for JS/CSS files, which loads only the s2Member plugin, and excludes all others to streamline the delivery of dynamic JS/CSS files for s2Member. When /s2member-o.php loads WordPress, it only loads the s2Member plugin, and excludes all others, including all MU plugins (which will also exclude an s2-hacks.php file on purpose).

So, in short, the hack still works, but it requires a special MU plugin file name.

While s2Member does NOT load any other plugins through /s2member-o.php, it does allow for some special MU plugin file names to be used, so that in special cases, it’s still possible for developers to hack into the /s2member-o.php file. These special MU plugin files are ALWAYS loaded, even when it’s /s2member-o.php

/mu-plugins/s2member-o.php
/mu-plugins/s2member-a.php
/mu-plugins/s2-o.php
/mu-plugins/s2-a.php

I’ve updated the code sample here to include this important requirement.
http://www.s2member.com/faqs/#s2-faqs-stop-loading-css

You may create this directory and file: /wp-content/mu-plugins/s2-o.php

<?php
add_action("ws_plugin__s2member_after_loaded", "remove_s2_pro_css"); function remove_s2_pro_css()
	{
		remove_action("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
	}
?>
Posted: Tuesday Mar 27th, 2012 at 6:00 am #9194

Sorry Jason but that doesn’t seem to be working for me

Posted: Tuesday Mar 27th, 2012 at 8:02 am #9207
Staff Member

Hi Philly. Thanks for the follow-up.

I can confirm that changing the file name to s2-o.php does work as expected. The expected outcome is that s2Member’s CSS for Pro Forms is NOT loaded into the CSS file. The CSS file does still load however. It’s just that Pro Form CSS styles are excluded.

If you want to exclude ALL of s2Member’s CSS in one shot. You can simply create this hack file instead.
/wp-content/mu-plugins/s2-hacks.php

<?php
add_action("ws_plugin__s2member_during_add_css", "remove_all_s2_css"); function remove_all_s2_css()
	{
		wp_dequeue_style("ws-plugin--s2member");
	}
?>
Viewing 4 replies - 1 through 4 (of 4 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.