Title: Gutenberg wordpress javascript on editor
Last modified: January 12, 2023

---

# Gutenberg wordpress javascript on editor

 *  [dexod](https://wordpress.org/support/users/dexod/)
 * (@dexod)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/gutenberg-wordpress-javascript-on-editor/)
 * Hello all,
 * I have been struggling with this one for a while, I have recently switched from
   Flexible Layouts to Blocks using ACF. The issue I have now is, I have all my 
   scripts in the scripts.js file, that initiates things like Slick Slider, and 
   other custom code for elements.
 * While on the front-end the website looks normal, and all the block function as
   they should, the Javascript is not being loaded in the back-end editor. I tried
   including the script file, but it seems like the DOMLoaded event the preview 
   of the block is still not being displayed, so the script never links up to it.
 * Is there any way to trigger the javascript for the blocks after they have been
   displayed in the preview editor.

Viewing 1 replies (of 1 total)

 *  [Benedikt Ledl](https://wordpress.org/support/users/benniledl/)
 * (@benniledl)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/gutenberg-wordpress-javascript-on-editor/#post-16369704)
 * Hi, how are you including the script?
 * Are you enqueuing it on a hook?
 * If yes, maybe these hooks can help
 * [https://developer.wordpress.org/reference/hooks/enqueue_block_editor_assets/](https://developer.wordpress.org/reference/hooks/enqueue_block_editor_assets/)
   
   Also you could try hooking onto this [https://developer.wordpress.org/reference/functions/add_editor_style/](https://developer.wordpress.org/reference/functions/add_editor_style/)
    -  This reply was modified 3 years, 4 months ago by [Benedikt Ledl](https://wordpress.org/support/users/benniledl/).

Viewing 1 replies (of 1 total)

The topic ‘Gutenberg wordpress javascript on editor’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Benedikt Ledl](https://wordpress.org/support/users/benniledl/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/gutenberg-wordpress-javascript-on-editor/#post-16369704)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
