{"action":"opened","issue":{"url":"https://api.github.com/repos/bevacqua/dragula/issues/16","labels_url":"https://api.github.com/repos/bevacqua/dragula/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/bevacqua/dragula/issues/16/comments","events_url":"https://api.github.com/repos/bevacqua/dragula/issues/16/events","html_url":"https://github.com/bevacqua/dragula/issues/16","id":69247943,"number":16,"title":"Can't load dragula in <head>","user":{"login":"rfunduk","id":6437,"avatar_url":"https://avatars.githubusercontent.com/u/6437?v=3","gravatar_id":"","url":"https://api.github.com/users/rfunduk","html_url":"https://github.com/rfunduk","followers_url":"https://api.github.com/users/rfunduk/followers","following_url":"https://api.github.com/users/rfunduk/following{/other_user}","gists_url":"https://api.github.com/users/rfunduk/gists{/gist_id}","starred_url":"https://api.github.com/users/rfunduk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfunduk/subscriptions","organizations_url":"https://api.github.com/users/rfunduk/orgs","repos_url":"https://api.github.com/users/rfunduk/repos","events_url":"https://api.github.com/users/rfunduk/events{/privacy}","received_events_url":"https://api.github.com/users/rfunduk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-18T00:43:26Z","updated_at":"2015-04-18T00:43:26Z","closed_at":null,"body":"It seems when loading dragula in `<head>`, the local `body` variable is `null`, which causes all kinds of problems. It seems this is due to `document.body` being `null` at the time `body` is defined: https://github.com/bevacqua/dragula/blob/master/dragula.js#L5\r\n\r\nTo state the obvious -- I know the ideal solution here is \"don't put your scripts in `<head>`\", but unfortunately I have a very large codebase that does exactly that :expressionless:... Maybe dragula could support this? I'd be happy to attempt a PR if you're amenable to it.\r\n\r\nHere's a demo showing the problem: http://ryanfunduk.com/dragula-test.html\r\nSame page but loading at EOB: http://ryanfunduk.com/dragula-works.html\r\n\r\nThanks for dragula, btw! It's looking like the drag&drop lib of my dreams :)"}}