Home Forums Gutenberg How to make Custom Block load JS file only in the editor


How to make Custom Block load JS file only in the editor

    • city17

    • September 8, 2019 at 12:48 am

    Hi, I’m working a custom block where I want to have separate files Script files for the front-end and editor.

    I found that when making a completely custom block you can use the 'enqueue_block_editor_assets‘ hook, but I’m not sure how to apply this to ACF’s way of creating custom blocks.

    It seems like with ACF only enqueue script and enqueue style are supported, which always load the same file for the editor and the front-end.

    Is there a way to make this (or some other method) work with ACF custom blocks?

  • @city17 – Did you by any chance get any further with this?

    • city17

    • November 26, 2019 at 5:35 am

    I didn’t find a proper solution, but I found a way around it on Stackexchange: See the answer here: (basically onload event on an empty image….strange, but it works).

  • Ah… interesting + strange indeed! Will check it out. Thanks for your swift reply 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.