Title: Javascript Plugin Development (external JS files vs wp_enqueue_script)
Last modified: August 31, 2016

---

# Javascript Plugin Development (external JS files vs wp_enqueue_script)

 *  [TakiToney](https://wordpress.org/support/users/takichicken/)
 * (@takichicken)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/javascript-plugin-development-external-js-files-vs-wp_enqueue_script/)
 * Hi, I’m developing a plugin for work and I’m basically learning how to develop
   plugins for the first time. I have a question about using javascript hardcoded
   in the main php file for the plugin and linking to the external javascript files.
 * Basically I can use document.write() if I hard code it into the plugin but, if
   I try to use wp_enqueue_script the javascript works but, document.write doesn’t
   seem to work.
 * So this works
 *     ```
       echo '<h1>Clean Post Search Settings</h1></p>
       <p>		<h2>Add/Edit Topics</h2>';?><br />
       		<script><br />
       		document.open();<br />
       		document.write("<h1>Main title</h1>");<br />
       		document.close();<br />
       		</script></p>
       <p>
       ```
   
 * But, document.write doesn’t work here
 * PHP
 *     ```
       </p>
       <p>function cps_zt_settings_page(){<br />
       	echo '<h1>Clean Post Search Settings</h1></p>
       <p>		<h2>Add/Edit Topics</h2>';<br />
       		wp_enqueue_script(cps_zt_js);<br />
       }<br />
       ```
   
 * External Javascript file
 *     ```
       <br />
       document.open();<br />
       document.write("<h1>Hello World</h1>");<br />
       document.close();<br />
       ```
   

The topic ‘Javascript Plugin Development (external JS files vs wp_enqueue_script)’
is closed to new replies.

## Tags

 * [external-javascript](https://wordpress.org/support/topic-tag/external-javascript/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [plugin-development](https://wordpress.org/support/topic-tag/plugin-development/)
 * [wp_enqueue_script](https://wordpress.org/support/topic-tag/wp_enqueue_script/)

 * 0 replies
 * 1 participant
 * Last reply from: [TakiToney](https://wordpress.org/support/users/takichicken/)
 * Last activity: [9 years, 12 months ago](https://wordpress.org/support/topic/javascript-plugin-development-external-js-files-vs-wp_enqueue_script/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
