Title: defer javascript loading
Last modified: December 2, 2024

---

# defer javascript loading

 *  [agile_pixel](https://wordpress.org/support/users/agile_pixel/)
 * (@agile_pixel)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/defer-javascript-loading-2/)
 * I would like to propose deferring the loading of the compset.js to the footer
   if that’s possible?
 * wp_enqueue_script(‘dfrcs_compsets’, DFRCS_URL . ‘js/compsets.js’, array(‘jquery’),
   DFRCS_VERSION, true);
 * It’s single line change in actions.php, this would help with performance and 
   is a best practice for loading javascript.
 * If moving to the footer is not possible, perhaps deferring the javascript instead?

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

 *  Thread Starter [agile_pixel](https://wordpress.org/support/users/agile_pixel/)
 * (@agile_pixel)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/defer-javascript-loading-2/#post-18174040)
 * Or if it’s not for everyone having it as an option in the CMS
 *  Plugin Author [datafeedr](https://wordpress.org/support/users/datafeedrcom/)
 * (@datafeedrcom)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/defer-javascript-loading-2/#post-18174786)
 * Hi
 * You can add the following code to a custom plugin to load the compsets.js file
   either in the footer or use defer (or both… it’s up to you).
 *     ```wp-block-code
       add_action( 'wp_enqueue_scripts', 'modify_dfrcs_compsets_script', 10000000 ); // Priority must be higher than the original enqueue function.function modify_dfrcs_compsets_script() {		// Dequeue the original script	wp_dequeue_script( 'dfrcs_compsets' );	// Re-enqueue the script in the footer	wp_enqueue_script(		'dfrcs_compsets',		DFRCS_URL . 'js/compsets.js',		array( 'jquery' ),		DFRCS_VERSION,		true // Set to true to load in the footer	);}
       ```
   
 * Here’s how to add a custom plugin to your site: [https://datafeedrapi.helpscoutdocs.com/article/32-creating-your-own-custom-plugin](https://datafeedrapi.helpscoutdocs.com/article/32-creating-your-own-custom-plugin)
 * Hope this helps!

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

The topic ‘defer javascript loading’ is closed to new replies.

 * ![](https://ps.w.org/datafeedr-comparison-sets/assets/icon-256x256.png?rev=1388272)
 * [Datafeedr Comparison Sets](https://wordpress.org/plugins/datafeedr-comparison-sets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/datafeedr-comparison-sets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/datafeedr-comparison-sets/)
 * [Active Topics](https://wordpress.org/support/plugin/datafeedr-comparison-sets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/datafeedr-comparison-sets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/datafeedr-comparison-sets/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [datafeedr](https://wordpress.org/support/users/datafeedrcom/)
 * Last activity: [1 year, 5 months ago](https://wordpress.org/support/topic/defer-javascript-loading-2/#post-18174786)
 * Status: not resolved