basanth
Member
Posted 3 years ago #
Hai Friends,
Where to place a javascript file in a theme?How to call that javascript file?Do we need to create a folder like "SCRIPTS" in a theme and call them as <script type="text/javascript" src="/scripts/filename.js"></script>?Please let me know the solution
Regards
Basanth
You can place script files in a "scripts" directory within your theme's directory and then source them with:
<script type="text/javascript" src="<?php bloginfo("template_url"); ?>/scripts/filename.js"></script>
alternatively, you can use the the wp_enqueue_script function in your functions.php file.
<?php wp_enqueue_script( 'handle', 'src', 'deps', 'ver'); ?>
for information on this function see:
http://codex.wordpress.org/Function_Reference/wp_enqueue_script