-
-
Save mrbobbybryant/83c4a076da6dd67de3da to your computer and use it in GitHub Desktop.
<?php | |
/** | |
* Enqueue scripts and styles | |
*/ | |
function your_theme_enqueue_scripts() { | |
// all styles | |
wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.css', array(), 20141119 ); | |
wp_enqueue_style( 'theme-style', get_stylesheet_directory_uri() . '/css/style.css', array(), 20141119 ); | |
// all scripts | |
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '20120206', true ); | |
wp_enqueue_script( 'theme-script', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '20120206', true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'your_theme_enqueue_scripts' ); |
I think you should use CDN instead of the local files for a better page loading speed.
I think you should use CDN instead of the local files for a better page loading speed.
Using CDN is not accepted for WordPress (or ClassicPress) themes because of GDPR and security/performance reasons (a CDN calls an external service, that could go down for any reason if their servers are down, moreover on that server someone might upload malicious code that gets executed at the time your theme makes the call, you do not maintain Bootstrap server and no server is 100% secure so it is not a good idea to rely on them). You need to host resources locally, and for Bootstrap, all it takes is just adding two files (a CSS and a JS file) to your assets. this won't slow the website down and is a more secure way to supply Bootstrap in your theme.
@ElisabettaCarrara and how do you ensure that your own server is secure? More secure than the CDN servers? Also, which GDPR clause are you referring to when you mention that using CDN is not allowed because of GDPR?
In addition to the above code, you also need to ensure that your css and js files are located in the above directories within your theme folder. ( /css/bootstrap.css )