elementor / elementor/elementor
🐞 Bug report: before_enqueue_scripts and after_enqueue_scripts write to HEAD in EDITOR
- Dominant language
- PHP
- Stars
- 7.1k
- Forks
- 1.6k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 193
Description
### Prerequisites
- [X] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- [X] The issue still exists against the latest stable version of Elementor.
### Description
JavaScript enqueue correctly in preview but not in editor. i.e. The `` tag loads in body viewing the site, and loads in `<head>` when the editor - causing my app to fail.
This happiness with both elementor/editor/before_enqueue_scripts and elementor/editor/after_enqueue_scripts
PS: I opened this issue before but was closed incorrectly - https://github.com/elementor/elementor/issues/17879
### Steps to reproduce
```
class Elementor_my_plugin extends \Elementor\Widget_Base {
public function get_script_depends() {
wp_register_script( 'my-widget', 'https://myscript.com' );
return ['my-widget'];
}
protected function render() {
echo '<div>Howdy</div>';
add_action( 'elementor/editor/after_enqueue_scripts', function() {
wp_enqueue_script( 'my-widget' );
});
}
}
```
### Isolating the problem
- [X] This bug happens with only Elementor plugin active (and Elementor Pro).
- [ ] This bug happens with a Blank WordPress theme active ([Hello theme](https://wordpress.org/themes/hello-elementor/)).
- [X] I can reproduce this bug consistently using the steps above.
### System Info
see previous ticket - https://github.com/elementor/elementor/issues/17879
Contributor guide
Assessment
This issue has not been assessed yet.