• Resolved Hien D. Nguyen

    (@hiendnguyen)


    Hi,

    Below js is always loaded in every single page.

    <!– OneAll.com / Social Login for WordPress / v5.3 –>
    <script data-cfasync=”false” type=”text/javascript”>
    (function() {
    var oa = document.createElement(‘script’); oa.type = ‘text/javascript’;
    oa.async = true; oa.src = ‘https://vntesters.api.oneall.com/socialize/library.js&#8217;;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(oa, s);
    })();
    </script>
    <style type=”text/css” media=”print”>#wpadminbar { display:none; }</style>
    <style type=”text/css” media=”screen”>
    html { margin-top: 32px !important; }
    * html body { margin-top: 32px !important; }
    @media screen and ( max-width: 782px ) {
    html { margin-top: 46px !important; }
    * html body { margin-top: 46px !important; }
    }
    </style>

    Is there any option to just load it in Login Page?

    Thanks,
    Hien

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Claude

    (@claudeschlesser)

    Hi Hien,

    yes, to give you the best flexibility, it’s loaded on every page. This allows you to simply embed the plugin by using a shortcode or by using JavaScript.

    The JavaScript is loaded asynchronously, so it will never block or slowdown the loading of your page. It’s also cached, so it will actually only be loaded once by the browser and then the cached version will be used.

    Do not hesitate to get back to use if you have any other questions.

    Thread Starter Hien D. Nguyen

    (@hiendnguyen)

    This one as well https://[name].api.oneall.com/socialize/library.js

    GTMetrix is showing that these are sources of performance issue.

    -Hien

    Plugin Author Claude

    (@claudeschlesser)

    Could you please post a link to the tool that you are using?

    Thread Starter Hien D. Nguyen

    (@hiendnguyen)

    Plugin Author Claude

    (@claudeschlesser)

    Hello,

    what I get from gtmetrix is this notice:

    Leverage browser caching for the following cacheable resources:
    http://oneall.api.oneall.com/socialize/library.js (4 hours)

    4 hours cache is the compromise between keeping the JavaScript up-to-date and allow the browser to cache it.

    Do you have any other messages?

    Thread Starter Hien D. Nguyen

    (@hiendnguyen)

    No. I got same message. So the file will be cached for 4 hours and you think it’s good enough.

    Thanks for all your inputs. I appreciate that.

    Thread Starter Hien D. Nguyen

    (@hiendnguyen)

    FYI, I could remove these extra script by using remove_action, wp_dequeue_script, wp_deregister_script. It saves loading page some time (2.2s reported by gtmetrix)…
    – Before: https://gtmetrix.com/reports/vndeveloper.com/NAuUEwxn
    – After: https://gtmetrix.com/reports/vndeveloper.com/Bx6OOZy3

    Snippets are below to whom it may concern

    if(is_user_logged_in() || !is_account_page()){
    		# style
    		wp_deregister_style('oa_social_login_admin_css');
    		wp_dequeue_style('oa_social_login_admin_css');
    		wp_deregister_style('oa_social_login_link_css');
    		wp_dequeue_style('oa_social_login_link_css');
    		wp_deregister_style('css_theme_uri');
    		wp_dequeue_style('css_theme_uri');
    		# script
    		wp_deregister_script('oa_social_login_admin_js');
    		wp_dequeue_script('oa_social_login_admin_js');
    		wp_deregister_script('oa_social_library');
    		wp_dequeue_script('oa_social_library');
    		# action
    		remove_action('login_head', 'oa_social_login_add_javascripts');
    		remove_action('wp_head', 'oa_social_login_add_javascripts');
    		remove_action('show_user_profile', 'oa_social_login_add_javascripts');
    		remove_action('login_form', 'oa_social_login_render_login_form_wp_login');
    		remove_action('wppb_before_login', 'oa_social_login_render_login_form_login');
    		remove_action('bp_before_sidebar_login_form', 'oa_social_login_render_login_form_login');
    		remove_action('va_after_admin_bar_login_form', 'oa_social_login_render_login_form_login');
    		remove_action('sidebar_login_widget_logged_out_content_end', 'oa_social_login_render_login_form_login');
    		remove_action('woocommerce_login_form_end', 'oa_social_login_render_login_form_login');
    		remove_action('register_form', 'oa_social_login_render_login_form_wp_registration');
    	}

    I tried putting this in my functions.php file, I replaced account page with !is_single() but it didn’t work. It removed the code from everywhere. Anyway to just keep scripts limited to single.php or where the comment is enabled. It does improve the page loading time by 25%. Thanks

    Thread Starter Hien D. Nguyen

    (@hiendnguyen)

    @zvhipp I am glad that it’s helpful for you.

    I used WooCommerce for user management so it will be much different if you don’t use WooCommerce since “!is_account_page()” always returns “True” which will remove the code from everywhere.

    Thank you. I actually used ‘plugin load filter’ plugin, which allowed me to take care of this. It’s working as I wanted now.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Javascript always loaded?’ is closed to new replies.