Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Do professional WordPress developers use and add JavaScript to their websites?

I'm not talking about JavaScript components like carousels etc I'm talking about adding JavaScript frameworks like Jquery, Angular, Node.JS, and so on, is it a valid appoach? Is it practical in the real-world?

I understand you can add CSS frameworks like bootstrap, foundations etc into your websites, but what about JavaScript? Can you add JavaScript frameworks the same way you can add bootstrap? Thanks.

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,705 Points

Adding JS is just as easy as adding CSS files and Boostrap.. In fact they use the same hook.

Take a look at this example or how to add scripts to your functions.php file

<?php
function wpt_scripts() {

    wp_enqueue_script('file_handle', get_template_directory_uri() . 'js/scriptfile.js');

}
//Then add the hook
add_action('wp_enqueue_scripts', 'wpt_scripts');
?>