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 that you have read and understand our privacy policy and code of conduct.

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