1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

"async" atribute loading javascript

Discussion in 'JavaScript' started by postcd, May 1, 2014.

  1. #1
    Hello,

    Google Insights https://developers.google.com/speed/pagespeed/insights/

    advices this:
    so i editted my code so its now:
    But after retesting, google still complaints, any idea please?
     
    postcd, May 1, 2014 IP
  2. hdewantara

    hdewantara Active Member

    Messages:
    302
    Likes Received:
    10
    Best Answers:
    9
    Trophy Points:
    68
    #2
    Hi Postcd.
    If I'm not mistaken, that means to put that jQuery CDN to the end of your HTML content block... so it would be the last to be rendered. So putting it just before the closing </body> tag will make Google happy, I think:)
     
    hdewantara, May 1, 2014 IP
    deathshadow likes this.
  3. deathshadow

    deathshadow Illustrious Member

    Messages:
    6,773
    Likes Received:
    1,021
    Best Answers:
    170
    Trophy Points:
    445
    #3
    Yeah, that Async attribute really doesn't do **** in most browsers anyways, and anyone telling you otherwise doesn't know ****.

    @hdewantara has it right in that you should move it to the end of the document, or at the very least into BODY. Any GOOD scripting should be attaching itself after that point -- but beware that you might have some poorly written scripts (pretty much a given once that steaming pile of halfwit bloated maggot ridden garbage known as jQuery is in the picture) that will require jQuery to load before they can run -- in which case either get rid of that stupid malfing jQuery nonsense, or move it into the start of BODY.

    Also, beware that moving it CAN result in slower pageloads -- the opposite of what Google tells you. It's good practice to move it, but don't trust it. Try it both ways, and test yourself using the waterfalls in tools like FireBug or Dragonfly. A LOT of what automated tools like pageSpeed tells you can actually be the opposite of what you need to do, as like a lot of automated tools they try to be a "one size fits all" solution -- and when you do that you end up jack of all trades, but master of none.

    In fact, there are a few things it says that are outright bullshit if you have a well written site; but to their credit most websites aren't well written.
     
    deathshadow, May 1, 2014 IP