You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/widgets/widget-dependencies.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,15 +108,35 @@ class Elementor_Test_Widget_2 extends \Elementor\Widget_Base {
108
108
109
109
This way, Elementor can build the dependency tree and enqueue only dependencies for widgets used in the page.
110
110
111
+
### Using Elementor Assets
112
+
113
+
Third-party developers can use assets registered by Elementor, for instance using [Swiper](https://swiperjs.com/) to create carousel-based widgets.
114
+
115
+
```php
116
+
class Elementor_Test_Widget extends \Elementor\Widget_Base {
117
+
118
+
public function get_style_depends(): array {
119
+
return [ 'swiper', 'widget-custom-style' ];
120
+
}
121
+
122
+
public function get_script_depends(): array {
123
+
return [ 'swiper', 'widget-custom-script' ];
124
+
}
125
+
126
+
}
127
+
```
128
+
129
+
Elementor registers swiper for its carousel widgets, and Elementor Pro and many other Elementor Addons use it instead of registering its own versiosn of the library.
130
+
111
131
### Using Elementor Scripts
112
132
113
-
Widgets can also use scripts registered by Elementor:
133
+
To use different Elementor JS methods, widgets needs to declare `elementor-frontend` as a dependency:
114
134
115
135
```php
116
136
class Elementor_Test_Widget extends \Elementor\Widget_Base {
0 commit comments