Home › Forums › Gutenberg › Conditionally Enqueueing Files if Page Contains Custom Block › Reply To: Conditionally Enqueueing Files if Page Contains Custom Block
Sometimes adding scripts / libraries to Gutenberg Editor (backend) cause serious problems. In case someone else have problems you can simply use if(! is_admin()) inside enqueue_assets, like so:
` ‘enqueue_assets’ => function () {
// Load assets only on frontend – the libs cause unwanted sideeffects in gutenberg
if(! is_admin()){
wp_enqueue_script(‘filtrify’, get_stylesheet_directory_uri() . ‘/libraries/stuff/js/foo.min.js’, array(‘jquery’), null, true);
}
},
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.