Originally published at: http://www.sitepoint.com/an-introduction-to-asset-handling-in-wordpress/
As a WordPress theme or plugin developer, there will come a time during your development process that you will need to include third party scripts or stylesheets in your plugin or theme. Sure, simply linking the assets in the header or footer would definitely work, but adhering to standard practice using the provided WordPress API will ensure that your theme or plugin will play nice with other plugins in the WordPress ecosystem.
If you want to provide maximum compatibility with other plugins and themes available, asset handling in WordPress is definitely a skill you should master.
This article is targeted to the beginner WordPress developer, with the assumption that you have a working knowledge of how WordPress action and filter hooks work.
The Basics
WordPress has provided a few basic functions to help the developer correctly load custom assets of their theme or plugin. The four main functions that you will use frequently are wp_register_script
, wp_enqueue_script
, wp_register_style
and wp_enqueue_style
.
Let’s go through these four major functions one by one.
Continue reading this article on SitePoint