How to add jQuery code into HTML Page

前端 未结 6 1613
天涯浪人
天涯浪人 2020-12-05 09:51

$(\".icon-bg\")         


        
6条回答
  •  悲哀的现实
    2020-12-05 10:14

    I would recommend to call the script like this

    ...
    
    
    
    

    The js and css files must be treat differently

    Put jquery as the first before other JS scripts at the bottom of tag

    • The problem caused is that they block parallel downloads. The HTTP/1.1 specification suggests that browsers download no more than two components in parallel per hostname.
    • So select 2 (two) most important scripts on your page like analytic and pixel script on the tags and let the rest including the jquery to be called on the bottom tag.

    Put CSS style on top of tag after the other more priority tags

    • Moving style sheets to the document HEAD makes pages appear to be loading faster. This is because putting style sheets in the HEAD allows the page to render progressively.
    • So for css sheets, it is better to put them all on the tag but let the style that shall be immediately rendered to be put in