- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Where should jQuery code go in header or footer?
It’s always a good practice to add jQuery code in footer i.e. just before the closing </body> tag. If you have not done that, then use the defer attribute.
Use defer attribute so the web browser knows to download your scripts after the HTML downloaded −
<script src="new.js" defer="defer"></script>
The defer attribute is used to specify that the script execution occurs when the page loads. It is useful only for external scripts and is a boolean attribute.
The following code shows how to use the defer attribute −
<!DOCTYPE html> <html> <body> <script src="new.js" defer></script> <p>The external file added will load later, since we're using defer</p> </body> </html>
- Where should the Google Analytics Tracking Code be placed?
- jQuery :header Selector
- Where do Jains go for pilgrimage?
- Being a beginner, should I go for blue-chip companies or mid-cap to invest in a mutual fund?
- Where do we use $.extend() method in jQuery?
- How should I initialize jQuery in a web page?
- Where we should close a connection in JDBC and MySQL?
- How to specify where a Tkinter window should open?
- Bootstrap panel-footer class
- HTML DOM Footer object
- Include a header for a document or section in HTML5?
- How do we create a footer for a document or section in HTML5?
- How do we specify whether a header cell is a header for a column, row, or group of columns or rows in HTML?
- Where should I put <script> tags in HTML markup?