douao3636 2013-11-05 01:09
浏览 55

从Wordpress主页中删除CSS和JS文件以增加Pagespeed?

With the reference of wordpress load plugin css/js in functions.php w/ conditional tags answered by @maiorano84

i am using cforms, FancyBox, WP Page Numbers plugins for Wordpress. From Page Speed point of view i want to remove CSS and JS of these plugin's from all pages except single post page. I also want to put the JS scripts in the footer. below is the code i have been trying but no luck. Would any body help me please?

if ( !is_single() ) {
add_action( 'wp_print_styles', 'my_deregisters', 100 );
add_action( 'wp_print_scripts', 'my_deregisters', 100 );

    function my_deregisters() {
        remove_action('wp_head', 'wp_page_numbers_stylesheet');
        wp_deregister_style( 'fancybox' ); 
        wp_deregister_script( 'fancybox' ); 
        wp_dequeue_script('fancybox');      
        wp_dequeue_style('fancybox'); 
        remove_action('wp_print_scripts', 'mfbfw_load');
        remove_action('wp_print_styles', 'mfbfw_css');
        remove_action('wp_head', 'mfbfw_init');
        remove_action('wp_head', 'cforms_style');

        }

} else {  }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 有没有帮写代码做实验仿真的
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥30 vmware exsi重置后登不上
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
    • ¥20 yolov5自定义Prune报错,如何解决?
    • ¥15 电磁场的matlab仿真