Reputation: 2591
I'm not sure if i shell use cdn or local. Does local means the jquery resources need to be installed on the smartphone, so that an offline app is possible ?
Upvotes: 1
Views: 3055
Reputation: 10221
Local, in this case, means that you host the files yourself (as part of your website), rather than relying on a CDN, also it does NOT mean they need to be installed on the device.
Once the libraries are downloaded, the application can be used without a data connection until the cache is cleared. Of course, this depends on your actual application, if it requires a data connection to query things on a server it won't work, but this has nothing to do with the offline availability of the JS libraries.
Either way, you will need a data connection at first.
The benefit of a CDN hosted library is that it might have been loaded for another website already, so when the users access your website they don't need to download it again.
However, there are other factors to consider, for example:
For jQueryMobile, however, it is more likely that another website is using it (and the same version) than it is with jQuery, so I would recommend using the CDN version.
Upvotes: 6
Reputation: 76003
The main benefit to using a CDN is that there is a chance that the user already has that file on their device and they can just load it from cache. Another benefit is that a CDN will normally be setup to properly compress the file as it's sent, greatly reducing the size of the file as it's transferred (jQuery 1.7 Core goes from about 90KB to 30KB when compressed). The CDN will probably have proper expiration headers as well, if you host the files on your own server, make sure to set it up to properly serve the files.
If you are creating a native application then you will probably want to host any JS files locally so it doesn't require a network connection to run the application.
If you are creating a web application then you can use a Cache Manifest to tell the browser which files to cache for when the user comes back to your site without a network connection.
Here is a tutorial to get started with Cache Manifests: http://www.html5rocks.com/en/tutorials/appcache/beginner/
I haven't given it a thorough read but MDN usually has some good documentation: https://developer.mozilla.org/en/Offline_resources_in_Firefox
Upvotes: 3