Title: JavaScript not added
Last modified: December 17, 2018

---

# JavaScript not added

 *  Resolved [fedetask](https://wordpress.org/support/users/fedetask/)
 * (@fedetask)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/javascript-not-added/)
 * Hi,
    I added this simple code to a WordPress post: `<button type="button" onClick
   ="doSomething()">Do Something</button>`
 * and in the
 * > This code will be included verbatim in <script> tags at the end of your page’s(
   > or post’s) …
 *  form I added the following code:
 *     ```
       function doSomething() {
       	console.log('called')
       }
       ```
   
 * I click `Update Scripts` and then `Preview`. In the preview page however, if 
   I click the button, nothing happens, and the console shows: `ReferenceError: 
   doSomething is not defined`. In fact, it turns out that my code is not present
   in the page. I’m using the Independent Publisher 2 theme. What could be the problem?

Viewing 1 replies (of 1 total)

 *  Thread Starter [fedetask](https://wordpress.org/support/users/fedetask/)
 * (@fedetask)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/javascript-not-added/#post-10998249)
 * Solved, don’t know what was the problem but now it works

Viewing 1 replies (of 1 total)

The topic ‘JavaScript not added’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/scripts-n-styles_46515d.svg)
 * [Scripts n Styles](https://wordpress.org/plugins/scripts-n-styles/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/scripts-n-styles/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/scripts-n-styles/)
 * [Active Topics](https://wordpress.org/support/plugin/scripts-n-styles/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/scripts-n-styles/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/scripts-n-styles/reviews/)

## Tags

 * [post](https://wordpress.org/support/topic-tag/post/)
 * [ReferenceError](https://wordpress.org/support/topic-tag/referenceerror/)

 * 1 reply
 * 1 participant
 * Last reply from: [fedetask](https://wordpress.org/support/users/fedetask/)
 * Last activity: [7 years, 6 months ago](https://wordpress.org/support/topic/javascript-not-added/#post-10998249)
 * Status: resolved