I'm wondering why...
<script type="text/javascript">
define('test', [], function() {
alert('Done') ;
}) ;
</script>
... doesn't work.
I'm using my own Framework which uses RequireJS if available, and calls define(name, dependencies, callback) ;
for every module loaded that requires another one.
But sometimes modules don't have dependencies, so dependencies
is an empty array.
Besides I know that...
require([], function() {
alert('Done') ;
}) ;
... works fine.
Could you explain me why the first method doesn't work ? Thanks.
Until you require the 'test' module, it will obviously not get called.
<script type="text/javascript">
define('test', [], function() {
alert('Done') ;
}) ;
require(['test'], function() {});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With