Where do you include the jQuery library from? Google JSAPI? CDN?

后端 未结 16 1973
攒了一身酷
攒了一身酷 2020-11-22 09:21

There are a few ways to include jQuery and jQuery UI and I\'m wondering what people are using?

  • Google JSAPI
  • jQuery\'s site
  • your own site/serv
16条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 10:26

    There are a few issues here. Firstly, the async load method you specified:

    
    
    

    has a couple of issues. Script tags pause the page load while they are retrieved (if necessary). Now if they're slow to load this is bad but jQuery is small. The real problem with the above method is that because the jquery.js load happens independently for many pages, they will finish loading and render before jquery has loaded so any jquery styling you do will be a visible change for the user.

    The other way is:

    
    

    Try some simple examples like, have a simple table and change the background of the cells to yellow with the setOnLoadCallback() method vs $(document).ready() with a static jquery.min.js load. The second method will have no noticeable flicker. The first will. Personally I think that's not a good user experience.

    As an example run this:

    
    
      Layout
      
    
    
    
    OneTwo
    ThreeFour
    FiveSix
    SevenNine
    NineTen

    You (should) see the table appear and then the rows go yellow.

    The second problem with the google.load() method is that it only hosts a limited range of files. This is a problem for jquery since it is extremely plug-in dependent. If you try and include a jquery plugin with a

提交回复
热议问题