Jump to content
Sign in to follow this  
j.silver

Doule Loading of jQuery Library

Recommended Posts

Dear all:

I know it is not usually normal to make double links of any file, however, since jQuery library can be linked to the page via the internet or locally, can we do both linking to achieve guaranteed loading if one fails and to make sure that getting the first link of the two would mean a faster loading? Is there any harm of doing so?

Share this post


Link to post
Share on other sites

Subsequent to posting the above question, I have done some more search on the topic and found two different opinions: one preferring local connection to be in the safe side should the jQuery library in the internet was down for whatever reason; the other is preferring the opposite, claiming to get faster linking especially on mobile devices. Both conflicting opinions might render the above question valid.

Share this post


Link to post
Share on other sites

There's no reason to do that. You're just making more work for the browser. You can check at any point if jQuery is loaded by checking for the jQuery object.

can we do both linking to achieve guaranteed loading if one fails and to make sure that getting the first link of the two would mean a faster loading?

No, because what happens in reality is that you wait for the slowest of the two before anything else will run. It's still going to download both files, and the ready event still isn't going to fire until everything is finished downloading.If you want to host your files on a CDN, fine, that's what they are for, low latency and high bandwidth. If you want to host locally, that's also fine. If you want to link to a file on a server that you have no control over then you're at the mercy of that server.

Share this post


Link to post
Share on other sites

Is hosting the files on CDN better than hosting them locally, especially with regards to speed of site loading, particularly on mobile devices? If there is a pro-con comparison between the two, it would help a lot.

 

When we say hosting locally do we mean downloading the jQuery file to one of our site's files, e.g. js, and linking to it there?

Share this post


Link to post
Share on other sites

Yes, I mean hosting on the same server as the rest of your site. As far as speed and latency goes, that depends entirely on the server and network that you're using. You can use your browser tools to run benchmark tests to check the load times of your server versus a CDN. A CDN will generally be faster.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...