{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/3751","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/3751/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/3751/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/3751/events","html_url":"https://github.com/magento/magento2/issues/3751","id":140494891,"number":3751,"title":"Question: How can i make JavaScript Asynchronous","user":{"login":"mayhem-ahmad","id":7792892,"avatar_url":"https://avatars.githubusercontent.com/u/7792892?v=3","gravatar_id":"","url":"https://api.github.com/users/mayhem-ahmad","html_url":"https://github.com/mayhem-ahmad","followers_url":"https://api.github.com/users/mayhem-ahmad/followers","following_url":"https://api.github.com/users/mayhem-ahmad/following{/other_user}","gists_url":"https://api.github.com/users/mayhem-ahmad/gists{/gist_id}","starred_url":"https://api.github.com/users/mayhem-ahmad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mayhem-ahmad/subscriptions","organizations_url":"https://api.github.com/users/mayhem-ahmad/orgs","repos_url":"https://api.github.com/users/mayhem-ahmad/repos","events_url":"https://api.github.com/users/mayhem-ahmad/events{/privacy}","received_events_url":"https://api.github.com/users/mayhem-ahmad/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/magento/magento2/labels/CS","name":"CS","color":"fad8c7"}],"state":"closed","locked":false,"assignee":{"login":"guz-anton","id":1562842,"avatar_url":"https://avatars.githubusercontent.com/u/1562842?v=3","gravatar_id":"","url":"https://api.github.com/users/guz-anton","html_url":"https://github.com/guz-anton","followers_url":"https://api.github.com/users/guz-anton/followers","following_url":"https://api.github.com/users/guz-anton/following{/other_user}","gists_url":"https://api.github.com/users/guz-anton/gists{/gist_id}","starred_url":"https://api.github.com/users/guz-anton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guz-anton/subscriptions","organizations_url":"https://api.github.com/users/guz-anton/orgs","repos_url":"https://api.github.com/users/guz-anton/repos","events_url":"https://api.github.com/users/guz-anton/events{/privacy}","received_events_url":"https://api.github.com/users/guz-anton/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-03-13T15:18:54Z","updated_at":"2016-03-15T15:59:11Z","closed_at":"2016-03-15T15:59:11Z","body":"Hey guys,\r\n\r\nI'm trying to us Html5 attribute async for these files :\r\n/requirejs/require.min.js\r\n/requirejs-min-resolver.min.js\r\n/mage/requirejs/mixins.min.js\r\n/requirejs-config.min.js\r\n\r\nbut i can't do it in magento cause it's XML tags and there is no head.phtml like magento1\r\nHelp plz "},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/196895754","html_url":"https://github.com/magento/magento2/issues/3751#issuecomment-196895754","issue_url":"https://api.github.com/repos/magento/magento2/issues/3751","id":196895754,"user":{"login":"guz-anton","id":1562842,"avatar_url":"https://avatars.githubusercontent.com/u/1562842?v=3","gravatar_id":"","url":"https://api.github.com/users/guz-anton","html_url":"https://github.com/guz-anton","followers_url":"https://api.github.com/users/guz-anton/followers","following_url":"https://api.github.com/users/guz-anton/following{/other_user}","gists_url":"https://api.github.com/users/guz-anton/gists{/gist_id}","starred_url":"https://api.github.com/users/guz-anton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guz-anton/subscriptions","organizations_url":"https://api.github.com/users/guz-anton/orgs","repos_url":"https://api.github.com/users/guz-anton/repos","events_url":"https://api.github.com/users/guz-anton/events{/privacy}","received_events_url":"https://api.github.com/users/guz-anton/received_events","type":"User","site_admin":false},"created_at":"2016-03-15T15:59:11Z","updated_at":"2016-03-15T15:59:11Z","body":"Hi @mayhem-ahmad ,\r\nI'm pleasantly surprised that's someone roots for client side performance.\r\n\r\n#### Here is some points about your question:\r\n\r\n1. Adding ```async``` to those ```<script>``` nodes **is not enough**. In most cases you will get random issues with JS app on the page. These files expect _to be loaded one by one_.\r\n2. As a solution for previous problem you can merge them manually. But ```requirejs-config.min.js``` is generated by application. So its hard to put it in bundle source.\r\n3. But on the own project with state list of Magento Modules you can pregenerate ```requirejs-config.min.js``` and switch off from page layout. So final solution near to workable one consists with\r\n  1. pregenerate ```requirejs-config.min.js``` \r\n  2. merge all mentioned files to one with preserving order of files\r\n  3. add this _bundle_  to xml declaration with filled async attribute. You can add ```async=\"async\"``` just in xml, where you will add you ```bundle.js```.  \r\nShould be something like:  \r\n```<script src=\"bundle.js\" async=\"async\"/>```  \r\nMore info could be found here http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html\r\n4. As the result should be one file loaded asynchronously.\r\n\r\n#### Some procedure notes:\r\n\r\n - Its better to ask questions on SE http://magento.stackexchange.com/  \r\n It has useful features for tracking particular question. And has wider community ready to give a hand.\r\n - Github Issues is more about _issues_ in source code. \r\nThanks for understanding.\r\n"}}