0

I just build a site use PJAX, I have include the jquery.min.js at the end of template html file. But when I load one page with js file link in it. The file just get an error:

$ is not defined 

I can't figure it out. Thank you all for your help!

2
  • 2
    It may be that your jquery reference is not above all your other scripts. Try putting it all the way at the top in the <head> tag, just for testing purposes. Commented Jun 5, 2014 at 18:01
  • yeah! test pass. Thank you! Commented Jun 5, 2014 at 18:11

1 Answer 1

1

This question explains the position of jQuery script.

You can see from this answer that people recommend putting the script at the bottom of the page, because it allows rendering of the page sooner. However, you can't reference the script if it hasn't been loaded yet.

If you don't fully understand how it works, no offense but I think it will be fine to load the script in the <head> as recommended above, you probably won't see too much rendering difference as a beginner.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.