Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8105409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:09:23+00:00 2026-06-06T00:09:23+00:00

I try to optimize my pages by putting some async attributes on my scripts.

  • 0

I try to optimize my pages by putting some async attributes on my scripts. It seems to break my javascript since $(document).ready is executed before the all scripts are loaded!

I saw that I can resolve my problem by putting $(window).load instead of $(document).ready but I was wondering if there is a better solution.
This solution trigger 2 problems in my case :

  1. I have to change all $(document).ready and tell all the developpers to not use it anymore
  2. The scripts will be executed after all images are loaded. My website has a lot of heavy images and I really need some scripts to be executed ASAP after dom is ready.

Do you have some magic tricks? Maybe putting all scripts at the end? use defer instead of async?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:09:25+00:00Added an answer on June 6, 2026 at 12:09 am

    After some extensive research, I can definitely say that putting scripts at the end of the page is THE best practice.

    Yahoo agrees with me : http://developer.yahoo.com/performance/rules.html#js_bottom

    Google don’t talk about this practice and seems to prefer async scripts : https://developers.google.com/speed/docs/best-practices/rtt#PreferAsyncResources

    IMHO, putting script at the end of the page has several benefits over async/defer:

    • It will work for all browser (yes, even IE 😉 )
    • You guarantee the execution order
    • You do not need to use $(document).ready or $(window).load
    • Your scripts can execute before your images are loaded
    • As async/defer, your page will be displayed quicker
    • When the DOM trigger the ready event, all scripts are loaded
    • Can be optimized by merging all js in one file without problem (by a tool like mod_pagespeed)

    The only drawback that I can see is that the browser won’t be able to parallelize the downloads.
    One good reason to use async/defer instead is when you have a script that is completly independant ( do not need to rely on the execution order) and that don’t need to be executed at a specific timing. Example : google analytics.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in a try to optimize some cassandra queries which I use the row
I try to optimize the database queries in Hibernate, but I found a blocker:
I would like to implement an B+ tree in Java and try to optimize
I have the following code pasted below. For some reason, the response.redirect seems to
I have gotten my basic L-System working and I decided to try and optimize
I'm testing my website to try and optimize it for speed using http://tools.pingdom.com .
I have some classes implementing some computations which I have to optimize for different
Having some problems while trying to optimize my SQL. I got 2 tables like
libsvm's grid.py try to optimize only two parameters c and g of svm-train. I
I am trying to optimize some stored procedures on a SQL Server 2000 database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.