In order to make it sure that everything workds harmoniously, we should use the standard WordPress method to load theme, plugins scripts and stylesheets.
Adding aditianal scripts and stylesheets to the WordPress is failry simple process. Principally you will create a funciton that will enqueue all the scripts and styles.
By using WordPress hook, it will find the required resources, let’s look at how to do so.
Enqueuing Scripts and Styles
The official way of adding scripts & styles to any theme is to enqueue them in the “functions.php” files using wp_enqueue_script(); or wp_enqueue_style(); methods.
Let’s take a look at the enqueue basic usage, to enqueue
wp_enqueue_style( 'style', get_stylesheet_uri() );
This will look for a stylesheet named “style” and load it.
If you wish to load CSS or JS file from the specific path, following methed will come in to use.
And in case you want to add files from a public url like wise fontawesome, take a look at following line of code:
Enqueue your script:
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer);
The enqueue function may look like this:
wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', array ( 'jquery' ), 1.1, true);
This is very basic and quite simple implementation, when you are developing custom themes.