Title: wp_enqueue_script does not load admin-forms in plugin page
Last modified: August 19, 2016

---

# wp_enqueue_script does not load admin-forms in plugin page

 *  Resolved [malaiac](https://wordpress.org/support/users/malaiac/)
 * (@malaiac)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-does-not-load-admin-forms-in-plugin-page/)
 * I have a plugin page …
    /wp-admin/admin.php?page=plugin.php
 * in plugin.php :
 *     ```
       $title = __('My plugin page','plugin');
       $parent_file = 'plugin.php';
       wp_enqueue_script('admin-forms');
       require_once('admin-header.php');
       ```
   
 * And still got no JS loading in the header…
    should be this one, like in edit.
   php : `<script type='text/javascript' src='http://www.mydomain.com/wp-admin/js/
   forms.js?ver=20080401'></script>`
 * anyone got a clue why ?

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

 *  [transom](https://wordpress.org/support/users/transom/)
 * (@transom)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-does-not-load-admin-forms-in-plugin-page/#post-848230)
 * Because in plugin.php – it is way too late. The headers have already been written
   by the time plugin.php is included.
 * The place to do this is in your plugin itself. I know that someone will have 
   a better way but in general, I code a small function and hook it to admin_head–
   i.e.
 *     ```
       function adminStuff () {
            wp_enqueue_script('admin-forms');
            return;
       }
       add_action('admin_head','adminStuff');
       ```
   
 * Then the js is loaded on every admin page. If you wanted to be neat about it –
   you could test for page = plugin.php in the function.
 *  Thread Starter [malaiac](https://wordpress.org/support/users/malaiac/)
 * (@malaiac)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-does-not-load-admin-forms-in-plugin-page/#post-848242)
 * ok .. admin.php is loaded way before plugin.php… should have think of that.
    
   still an ugly solution: it loads forms.js for every admin page, even when not
   needed… let’s roll with it.
 * Thanks !
 *  [volksman](https://wordpress.org/support/users/volksman/)
 * (@volksman)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-does-not-load-admin-forms-in-plugin-page/#post-848249)
 * > Then the js is loaded on every admin page. If you wanted to be neat about it–
   > you could test for page = plugin.php in the function.
 * Answers that problem too. Just test to see if your plugin page is being drawn
   before triggering your action.
 *  Thread Starter [malaiac](https://wordpress.org/support/users/malaiac/)
 * (@malaiac)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-does-not-load-admin-forms-in-plugin-page/#post-848321)
 * actually, ‘admin_head’ is still too late.
    ‘admin_init’ did the job.

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

The topic ‘wp_enqueue_script does not load admin-forms in plugin page’ is closed
to new replies.

## Tags

 * [script](https://wordpress.org/support/topic-tag/script/)

 * 4 replies
 * 3 participants
 * Last reply from: [malaiac](https://wordpress.org/support/users/malaiac/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-does-not-load-admin-forms-in-plugin-page/#post-848321)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
