Title: Adding javascript
Last modified: August 31, 2016

---

# Adding javascript

 *  [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * (@rdxcsgoid)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/)
 * I add javascript and jquery to my theme js file & it works fine.
    **For Example**
   My theme is virtue , I just go to main.js file & add my jquery there. Is there
   any harm adding jquery to my theme’s js file? Except that update thing. Also 
   I have to delete browser history everytime to make it work.

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960264)
 * It’s just not best practice. When you have the time, you should extract this 
   change into a Child Theme.
 *  Thread Starter [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * (@rdxcsgoid)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960267)
 * Hey , thanks for reply
    But what about deleting browser history , isnt there 
   any alternative to this. Every time I add any code , I have to delete history
   to make it work.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960269)
 * This is a browser issue and you can probably find browser addons that clear your
   cache for you
 *  Thread Starter [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * (@rdxcsgoid)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960275)
 * Browser issue? this happens in every browser . But how is it practical?
    After
   making website live , if i add any javascript it wont work for users untill they
   delete history if they have visited my site earlier. thanks.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960279)
 * You can add a parameter on the end of your JS file and change it so that the 
   browser doesn’t cache it.
 * For example:
 *     ```
       http://example.com/wp-content/themes/js/myjsfile?1
       ```
   
 * The parameter is this bit:
 *     ```
       ?1
       ```
   
 * Change the number if you release something to users.
 *  Thread Starter [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * (@rdxcsgoid)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960324)
 * Hey , not working for me . What i did
    1 ) Default location [http://example.com/wp-content/virtue/js/main.js](http://example.com/wp-content/virtue/js/main.js)
   2 ) Changed the file name to main?1.js 3 ) Opened the site , then added the new
   code 4 ) Changed the name to main?2.js but still not working without deleting
   history . Have i done anything wrong? Thanks
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960325)
 * Try:
 *     ```
       jQuery(".headerclass").click(function(){
       alert("hello");
   
       });
       ```
   
 *  Thread Starter [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * (@rdxcsgoid)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960329)
 * still not working without deleting history
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960330)
 * Can you link your site?
 *  Thread Starter [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * (@rdxcsgoid)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960331)
 * [https://cardmart.in](https://cardmart.in)
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960351)
 * Maybe try using this:
 *     ```
       ?v=1
       ```
   
 * Instead of:
 *     ```
       ?1
       ```
   
 *  Thread Starter [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * (@rdxcsgoid)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960358)
 * nope 🙁 still same
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960360)
 * To make sure it’s not browser specific, does the issue persist in another browser?
 *  Thread Starter [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * (@rdxcsgoid)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960367)
 * Yes , I have tested Opera , Chrome & Firefox

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

The topic ‘Adding javascript’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 14 replies
 * 2 participants
 * Last reply from: [rdxcsgoid](https://wordpress.org/support/users/rdxcsgoid/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-7/#post-6960367)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
