Why some Javascript doesn't work from footer.php?

Like, I have placed the sweetalert javascript file in footer and i got the error showing “swal is not defined” but when I placed the same path in header, it works, why this doesn’t work in footer?

It sounds like you might not have things loading and running in the right order.
i.e.

<script src="jquery.js"></script>
</head>
⋮
<script>
do_some_jquery_stuff();
</script>
</body>

should work, while this will not

<script>
do_some_jquery_stuff();
</script>
<script src="jquery.js"></script>
</body>

I usually put “base” / “library” calls into <head> and “do stuff” script before </body> regardless of Googles “blocking” notices.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.