4

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

$(window).load()
11

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

PHTML

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

Or JS

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

    // Your Code

    }(jQuery)
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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