Book Image

Practical Web Development

By : Paul Wellens
Book Image

Practical Web Development

By: Paul Wellens

Overview of this book

Table of Contents (23 chapters)
Practical Web Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
10
XML and JSON
Index

Where to place the jQuery library on your page?


Not everyone agrees on what the right thing to do here is. There is always a concern about the amount of time it takes to load a file. There is going to be a difference if you put the statement in the <head> section of your document or right before the closing </body> tag to load the jQuery library - for example:

<script src="./js/jquery/jquery.js"></script>

The concern is the time it takes to load the library. I sometimes place everything that is a library, in other words, something that delivers functionality without actually doing anything, in the head section of the file. This means that the functionality will be loaded before the HTML.

You will always use jQuery in conjunction with your own JavaScript file, for example, mycode.js. This file will contain your jQuery lines of code inside the following:

$(document).ready(function(){
  }

All the code you put there will be executed after your page is loaded. As a consequence...