I looked at #42 but it's not quite what I'm dealing with here. I have the actual script loaded in the head, but I initialize it at the end right before
. And it works, but when I open up DevTools I still see the error. I'm using this for my Rails application, so I don't know if that has anything to do with it. Any ideas on how I can get that error to go away? Or since I got it working, should I not worry about it?
Hi @marcnjaramillo,
Loading script in HEAD should work just fine so you can leave it there. It looks like in the place where you initialize AOS there is no body in DOM yet and it throws an error on this line of code:
document.querySelector('body').setAttribute('data-aos-easing', options.easing);
Can you confirm that document.querySelector('body') right before AOS.init() doesn't return null? If you initialize AOS in place where you can access body in DOM - it should not throw any error.
It happens because no attribute has been found due to the bad timing!
I had this happening because I called AOS.init before the whole DOM has been loaded. The solution is to call AOS.init() only within
$(document).ready(function(){
AOS.init({duration: 1000});
});
Most helpful comment
It happens because no attribute has been found due to the bad timing!
I had this happening because I called AOS.init before the whole DOM has been loaded. The solution is to call AOS.init() only within
$(document).ready(function(){
AOS.init({duration: 1000});
});