10

I'd like to execute my JS after the DOM ready using RequiredJS instead of this:

$(window).load()

1 Answer 1

26

You can use this feature of the RequiredJS 'domReady!' like the native Magento's modules use:

PHTML

<script>
        require(['jquery','domReady!'], function ($) {
            // Your Code
        });
</script>

Or JS

define(['jquery','domReady!'], function($) {

    // Your Code

    }(jQuery)
);
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.