Jump to content

Doule Loading of jQuery Library


j.silver

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?

Link to comment
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.

Link to comment
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.
Link to comment
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?

Link to comment
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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...