All Courses > Up and Running > Chapters > Including Custom Scripts and Styles In WordPress

Including Custom Scripts and Styles In WordPress

Key Takeaways:

The proper method to include JavaScript files and CSS stylesheets to WordPress is by enqueueing them. This allows for flexibility and customizability that adding these files directly to your site's header does not.
The function to enqueue a stylesheet is called wp_enqueue_style(). The function to enqueue a JavaScript file is called wp_enqueue_script(). Both functions most commonly hook into a WordPress action hook called wp_enqueue_scripts.
Properly enqueueing scripts and styles—and linking to theme and plugin resources in general—requires proper knowledge of WordPress's URL linking functions, which this chapter covers.

In this chapter, we'll cover one of the most commonly used sets of WordPress functions: the functions that enqueue files for inclusion into a WordPress site.

There are two types of enqueue-able files worth discussing:

JavaScript files: These add custom fu...