Dynamically add Js

I have a basic bunch of CSS/Js files defined in my functions.php file. There I register and enqueue those scripts and stylesheets.

But in specific situations I want to load additional scripts based on the site template which is used.

I tried to register and enqueue those additional scripts in the specific Template file, but it didnt work. It does only work when included in the functions.php.

What is the correct way to do this?

Topic wp-enqueue-style wp-enqueue-script Wordpress javascript

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.