// font awesome アイコンを読み込まない(JavaScriptで遅延読み込みさせるため)
function deregister_styles_font_awesome() {
  wp_deregister_style( 'font-awesome' );
  wp_register_style( 'font-awesome', '' );

  wp_deregister_style( 'font-awesome-animation' );
  wp_register_style( 'font-awesome-animation', '' );
}
add_action( 'wp_print_styles', 'deregister_styles_font_awesome' );

// 遅延読み込みのJavaScriptをインラインで挿入
function lazy_load_css() {
    echo '<script>
function lazyLoadCSS() {
  var fontawesome = "' . get_template_directory_uri() . '/css/fontawesome/css/font-awesome.min.css";
  var fontawesomeAnimation = "' . get_template_directory_uri() . '/css/fontawesome/css/font-awesome-animation.min.css";

  function addStyleHead(href) {
    var link = document.createElement("link"); link.rel = "stylesheet";
    link.href = href;
    document.head.appendChild(link);
  };
  var raf = requestAnimationFrame || mozRequestAnimationFrame ||
      webkitRequestAnimationFrame || msRequestAnimationFrame;
  if (raf) {
    raf(function (){
      addStyleHead(fontawesome);
      addStyleHead(fontawesomeAnimation);
    });
  } else {
    window.addEventListener("load", function(){
      addStyleHead(fontawesome);
      addStyleHead(fontawesomeAnimation);
    });
  }
}
lazyLoadCSS();
</script>';
}
add_action('wp_footer', 'lazy_load_css');

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.