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.

Removing the password strength meter script?

Home Forums Community Forum Removing the password strength meter script?

This topic contains 4 replies, has 2 voices. Last updated by  Cristián Lávaque 3 years, 7 months ago.

Topic Author Topic
Posted: Tuesday Jun 4th, 2013 at 12:08 pm #51333
TJ
Username: wellwater

On checkout pages, s2member includes/queue’s “password-strength-meter.min.js” (a core WordPress JavaScript file) alongside its own JavaScript form validation script.

Jason mentioned it can be hidden via CSS if we don’t want to use it, but this still results in an unnecessary script download and header response call. Therefore, I’d prefer to remove it entirely for the purpos of site speed optimization.

This technique (if put in functions.php) appears to really remove it without affecting s2member. This idea originates here: http://beneverard.co.uk/blog/wordpress-loading-jquery-correctly-version-2/

I wanted to run it by support to confirm if it’s ok:

// this goes in functions.php
if (strpos($_SERVER['REQUEST_URI'], '/checkout/') === 0) {
    function remove_password_meter()
    {
        // Deregister the original version of the password strength meter script.
        wp_deregister_script('password-strength-meter');

        // Register it again, this time with no file path.
        wp_register_script('password-strength-meter', '', false, false);

        // Add it back into the queue.
        wp_enqueue_script('password-strength-meter');
    }
    add_action('template_redirect', 'remove_password_meter');
}

If I just used

wp_deregister_script('password-strength-meter');

it would prevent s2member’s validation script from loading, but since I’m re-registering and re-queueing it as an empty file path, s2member thinks it’s still there and happily loads its own script without loading the password meter script.

By all appearances, it doesn’t look like s2member actually uses the file, even indirectly, so would this be safe to use?

By the way, I’ve been using the above technique to load jQuery (which s2member also specifies as a “dependent” script), and things have been running fine all this time.

I assume doing the same to the password meter script would be ok, but unlike my jQuery implementation, I’m not just repositioning the file–I’m taking it out of the picture altogether.

Thanks.

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Wednesday Jun 5th, 2013 at 11:30 pm #51448

I’ll ask Jason about it.

Posted: Thursday Jun 6th, 2013 at 11:54 pm #51560

He said that should work just fine. :)

Posted: Friday Jun 7th, 2013 at 12:22 am #51570
TJ
Username: wellwater

This is great. Thanks Cristián and Jason.

Posted: Saturday Jun 8th, 2013 at 12:48 am #51649

No problem. :)

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.