Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJoseph Anson
14,448 PointsHave I missed something? Why do we use php to include the stylesheets instead of a link tag in the html?
Why function instead of <link> ?
1 Answer
Jacob Mishkin
23,118 PointsWordPress has a strong developer community. Thousands of people around the world design themes and write plugins for WordPress. To make sure that everything works properly and no one is stepping on anotherβs toe, WordPress has an enqueue script function. This function provides a systematic way of loading JavaScripts and styles. By using wp_enqueue_script function, you tell WordPress when to load a script, where to load it, and what are itβs dependencies. This allows everyone to utilize the built-in JavaScript libraries that comes bundled with WordPress rather than loading the same third-party script multiple times. It also helps reduce page load time and avoid conflicts with other themes and plugins.
Joseph Anson
14,448 PointsJoseph Anson
14,448 PointsOh right ok, I thought it would take longer to load the page for some reason. Thanks!!
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 PointsNot a problem. It would take longer if you added the files inline. With WP_enqueue_scripts durring the WP load the styles and scripts are loaded during the actual WP load.