Title: Load javascript from external file with dependencies
Last modified: August 19, 2016

---

# Load javascript from external file with dependencies

 *  [jorge_ricardo](https://wordpress.org/support/users/jorge_ricardo/)
 * (@jorge_ricardo)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/load-javascript-from-external-file-with-dependencies/)
 * I’m trying to use javascript plugins that need jquery as a dependency. I tried
   almost everything and I can’t make it run. What I’ve done so far is:
    – Load 
   scripts in themes’ header.php (In header.php. Maskedinput and meiomask are the
   plugins I’m trying to use):
 *     ```
       <script src="/JavaScript/jquery.js" type="text/javascript"></script>
       <script src="/JavaScript/maskedinput.js" type="text/javascript"></script>
       <script src="/JavaScript/meiomask.js" type="text/javascript"></script>
       ```
   
 * – Enqueue/register plugins (still in header.php):
 *     ```
       <?php
       	wp_enqueue_script('handle_jquery', 'http://my_ip/JavaScript/jquery.js');
       	wp_register_script('handle_meiomask', 'http://my_ip/JavaScript/meiomask.js', array('handle_jquery'));
              wp_register_script('handle_maskedinput', 'http://my_ip/JavaScript/maskedinput.js', array('handle_jquery'));
       ?>
       ```
   
 * – Call function (in header.php, as required by plugin maskedinput):
 *     ```
       <script type="text/javascript">
          $(function() {
            $('input[@name=htmlDataInicio]').mask('99/99/9999');
          });
       </script>
   
       <script type="text/javascript">
       jQuery(function($){
          $("htmlDataInicio").mask("99/99/9999");
       });
       </script>
   
       <script type="text/javascript">
       jQuery(function($){
          $("#htmlDataInicio").mask("99/99/9999");
       });
       </script>
       ```
   
 * – Put alt=”wanted_mask” (as required by meiomask plugin):
 *     ```
       <p><b>Recursos: </b><input type="text" id="decimal" name="some_name" alt="decimal" /></p>
       ```
   
 * And the plugins don’t work.
 * Any help appreciated. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/load-javascript-from-external-file-with-dependencies/#post-1531860)
 *     ```
       <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/Javascript/jquery.js"></script>
       ```
   
 * does it work any better like this to load them?
 * (assuming the scripts are in a Javascript folder, in your theme)
 *  Thread Starter [jorge_ricardo](https://wordpress.org/support/users/jorge_ricardo/)
 * (@jorge_ricardo)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/load-javascript-from-external-file-with-dependencies/#post-1532292)
 * First of all, thanks RVoodoo.
    But my problem is not loading the scripts. I’ve
   loaded them and tested with a simple button and an alert message and it worked
   fine. So I guess they are loading. My problem is that maskedinput and meiomask
   plugins need jquery as a dependency. So my problem is wp_enqueue/wp_register 
   functions (or that’s what I think, at least). So, anyone knows how to make dependencies
   work?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Load javascript from external file with dependencies’ is closed to new
replies.

## Tags

 * [dependency](https://wordpress.org/support/topic-tag/dependency/)
 * [external](https://wordpress.org/support/topic-tag/external/)
 * [file](https://wordpress.org/support/topic-tag/file/)
 * [input](https://wordpress.org/support/topic-tag/input/)
 * [java](https://wordpress.org/support/topic-tag/java/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [load](https://wordpress.org/support/topic-tag/load/)
 * [masked](https://wordpress.org/support/topic-tag/masked/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [jorge_ricardo](https://wordpress.org/support/users/jorge_ricardo/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/load-javascript-from-external-file-with-dependencies/#post-1532292)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
