The way we load Javascript and CSS files in Wordpress is different from the normal HTML way.
First of all, we need to identify where do we want to load the scripts. Is it in our theme or plugin?.
Lets say we want to load it to our theme, we can easily create a new folder in our child theme and place the scripts in it. for example
Then we can load it in our child theme functions.php file. Ok when we load, we need to understand the parameters that we want to pass in... for wp_enqueue_styles is quite straight forward. but for wp_enqueue_script.. Pay attention on deps parameter. whether the script that we want to load has dependencies with other scripts / jquery. Same goes to in_footer parameter, do we want to load in header or before the body closing tag. If we do not define properly. Our scripts might not be loaded properly. Pay attention on those two parameters.
Comments
Post a Comment