Elgg version = 3.3.13
I use elgg_define_js( ) to register third-party JS libraries in a start.php file of my plugin. Some works but some does not.
Working
elgg_define_js('chart_js', [
'src' => '/mod/my_plugin/vendors/JS/Chart.js'
]);
Not Working
elgg_define_js('pptxgen_js', [
'src' => '/mod/my_plugin/vendors/JS/pptxgen.bundle.js'
]);
I am very curious why registering the second library does not work.
Clarification/suggestion would be greatly appreciated.
Thanks!
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- seri_ng@seri_ng
seri_ng - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- seri_ng@seri_ng
seri_ng - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
Note: pptxgen.bundle.js is located at: And got this error: Usually, it means an error in the JS code, or something else. Test it. If you have same error then I recommend to ask a vendor about this issue.
- seri_ng@seri_ng
seri_ng - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
You must log in to post replies.Any errors in the browser console?
My apologies for not providing the error message.
The error message says, 'JSZip is not defined'.
I used this library on a non-Elgg site and it works without the above error. So that's why I wonder that I might do something wrong with registering 3rd-party libraries via elgg_define_js( ).
Here is the library I want to register - https://gitbrent.github.io/PptxGenJS/docs/installation.html
Try this:
Thanks Nikolai for your suggestion.
I tried your recommended approach. Then I used elgg_require_js('JSZip') on the page that I want to use this library. Now it throws different error - "net::ERR_ABORTED 403 (Forbidden) require.js:1961".
Just tested on my localhost with this:
I couldn't replicate the error you got above after following your approach. The error I got was 'JSZip is not defined'. Anyways, I am going to search for other Elgg approaches to register 3rd-party JS libraries rather than elgg_define_js( ).
Thanks again Nikolai! Always much appreciated your help.
Yes, you can try elgg_register_external_file function.
Look at these examples.