Title: Adding JavaScript in order to save data more quickly
Last modified: June 29, 2025

---

# Adding JavaScript in order to save data more quickly

 *  [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [11 months, 2 weeks ago](https://wordpress.org/support/topic/adding-javascript-in-order-to-save-data-more-quickly/)
 * Are these 2 block of Js correct and where I have to put them? in function.php?
   [https://pastebin.com/2BSCb6NR](https://pastebin.com/2BSCb6NR)
 * I have a great number of custom fields, can I have a Js code working on all of
   them at the same time?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadding-javascript-in-order-to-save-data-more-quickly%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [Sandeep Dahiya](https://wordpress.org/support/users/sandeepdahiya/)
 * (@sandeepdahiya)
 * [11 months, 1 week ago](https://wordpress.org/support/topic/adding-javascript-in-order-to-save-data-more-quickly/#post-18532961)
 * Hi [@sacconi](https://wordpress.org/support/users/sacconi/)
 * This code seems to provide a functionality for real-time saving of custom field
   data in the WordPress admin area without requiring a full page refresh and it
   seems correct to me.
 * It is recommended to use the above code in a **child theme’s `functions.php`**
   file. This ensures your changes aren’t overwritten when the parent theme updates
   or if you want this function to work even when you change the theme, create a
   custom plugin file for this.
 * And Yes, you can have a single JavaScript code block that works on many custom
   fields simultaneously, provided they share a common characteristic, such as a
   class, a parent container, or a naming convention.
   Regards
    -  This reply was modified 11 months, 1 week ago by [Sandeep Dahiya](https://wordpress.org/support/users/sandeepdahiya/).
 *  Thread Starter [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [11 months, 1 week ago](https://wordpress.org/support/topic/adding-javascript-in-order-to-save-data-more-quickly/#post-18536617)
 * I put the 2 blocks of code in function.php and the site got broken…

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

The topic ‘Adding JavaScript in order to save data more quickly’ is closed to new
replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [sacconi](https://wordpress.org/support/users/sacconi/)
 * Last activity: [11 months, 1 week ago](https://wordpress.org/support/topic/adding-javascript-in-order-to-save-data-more-quickly/#post-18536617)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
