Title: Enqueue JS only where shortcode is used
Last modified: June 9, 2021

---

# Enqueue JS only where shortcode is used

 *  [Daniele Scasciafratte](https://wordpress.org/support/users/mte90/)
 * (@mte90)
 * [5 years ago](https://wordpress.org/support/topic/enqueue-js-only-where-shortcode-is-used/)
 * As it is now is included in all the pages…

Viewing 1 replies (of 1 total)

 *  Thread Starter [Daniele Scasciafratte](https://wordpress.org/support/users/mte90/)
 * (@mte90)
 * [5 years ago](https://wordpress.org/support/topic/enqueue-js-only-where-shortcode-is-used/#post-14536853)
 * I patched the Loader.php file has:
 *     ```
       public static function activate_frontend_scripts() : void {
               global $post;
   
       		if ( \is_a( $post, 'WP_Post' ) && \has_shortcode( $post->post_content, 'mail_encrypt' ) ) {
                   wp_enqueue_script(
                       'mail_encrypt.js',
                       self::$base . 'dist/js/mail-encrypt-frontend.js',
                       [],
                       null,
                       true
                   );
               }
           }
       ```
   
 * ‘

Viewing 1 replies (of 1 total)

The topic ‘Enqueue JS only where shortcode is used’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/mail-crypter_272628.svg)
 * [Email Protect](https://wordpress.org/plugins/mail-crypter/)
 * [Support Threads](https://wordpress.org/support/plugin/mail-crypter/)
 * [Active Topics](https://wordpress.org/support/plugin/mail-crypter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mail-crypter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mail-crypter/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Daniele Scasciafratte](https://wordpress.org/support/users/mte90/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/enqueue-js-only-where-shortcode-is-used/#post-14536853)
 * Status: not resolved