Gutenberg Script Loading
-
So im following the way to add styles/script in to the gutenberg editor as mentioned here:
https://jasonyingling.me/enqueueing-scripts-and-styles-for-gutenberg-blocks/Styles are coming in fine as expected, however scripts dont seem to be working as expected (possibly too early?).
The code being used is:
/** * Enqueue block JavaScript and CSS for the editor */ function my_block_plugin_editor_scripts() { // Enqueue block editor styles wp_enqueue_style('fontawesome', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'); wp_enqueue_style('site-css', get_template_directory_uri() . '/assets/styles/style.css', array(), filemtime(get_template_directory() . '/assets/styles/scss'), 'all'); wp_enqueue_style('slick-css', '//cdn.jsdelivr.net/npm/[email protected]/slick/slick.css'); wp_enqueue_style('slick-theme-css', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css'); // Enqueue block editor JS wp_enqueue_script('site-js', get_template_directory_uri() . '/assets/scripts/scripts.js', array('jquery'), filemtime(get_template_directory() . '/assets/scripts/js'), true); wp_enqueue_script('slick-js', 'https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.min.js', array('jquery'), true); } // Hook the enqueue functions into the editor add_action('enqueue_block_editor_assets', 'my_block_plugin_editor_scripts');
(Neat version here if formatting is off: https://pastebin.com/BfHpmmgW )
I can see in devtools that its adding all scripts in to the <Head>.
So, is the issue that its loading too early?
If so, how can i make it load later?Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Gutenberg Script Loading’ is closed to new replies.