3

When I run "themes check" , it recommends not to use CDN. I am using Bootstrap CDN this way

function underscore_bootstrap_wp_scripts() {

/*   bootstrap and font awesome and animate css  */
wp_enqueue_style( 'bootstrap_cdn', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' );
wp_enqueue_style( 'fontawesome_cdn', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );

/*   default underscores styles  */
wp_enqueue_style( 'underscore_bootstrap_wp-style', get_stylesheet_uri() );

/*  bootstrap js  */
wp_enqueue_script('bootstrap_js_cdn', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',array('jquery'),'',true);

/*   default underscores js  */
//wp_enqueue_script( 'underscore_bootstrap_wp-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'underscore_bootstrap_wp-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );

/* my stylesheet and js */
wp_enqueue_style( 'custom_style_css', get_template_directory_uri(). '/css/main.css' );
wp_enqueue_script('custom_js', get_template_directory_uri(). '/js/main.js',array('jquery','bootstrap_js_cdn'),'',true);

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    wp_enqueue_script( 'comment-reply' );
  }
}

The " Themes Check " Plugin shows -

RECOMMENDED: Found the URL of a CDN in the code: maxcdn.bootstrapcdn.com/font-awesome. You should not load CSS or Javascript resources from a CDN, please bundle them with the theme.

RECOMMENDED: Found the URL of a CDN in the code: maxcdn.bootstrapcdn.com/bootstrap. You should not load CSS or Javascript resources from a CDN, please bundle them with the theme.

5

Your theme should not depends on any external link library. There is no guarantee when that library can be taken down. That's the reason all of your theme assets should be package with theme, to prevent the future risk.

2

Like daniyalahmad said, it is better not to include links to external assets in your theme. A good example of this recently. I use a theme from MyThemeShop and they linked to external html5shim. Google just recently stopped hosting this and so I started to get a 404 on my website. It was easy for me to simply comment it out, but for typical users, this is a big problem.

There are now 1.5M instances of a dead html5shim googlecode URL on GitHub: https://www.reddit.com/r/programming/comments/4u47ak/15m_instances_of_a_dead_html5shim_googlecode_url/

When packaging a theme, always package it with it. And if you don't want to include it, write a tutorial for your users on how to deploy it after the fact. If they want to link externally that is usually fine, but not in base theme. I recommend checking font awesome CDN. It's free and is delivered from 25+ POPs over HTTP/2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.