![]() If using this on the same minor version of jQuery as above, here are the results: For example, Jsdelivr has a feature that allows one to leave off the exact version string (so that you can always get the latest patch version, for example) ( view their features page). IMPORTANT: Be careful about how CDN features might impact cache-control headers (in a way that would degrade performance for your users). Via jQuery's CDN ( url) compression: gzipĬache-control: public, max-age=31536000, s-maxage=31536000, immutable Be careful of performance impacts resulting from using specific CDN features.Ĭompare the same version of jQuery served by jQuery's CDN, jsDelivr, and cdnjs.Check the cache-control header (the longer it's set for the better, generally).This has direct impact on the payload size, though Brotli is not always smaller than Gzip (see below example). If the CDN is not using Brotli they're likely using gzip. The preferred option here is generally br (for Brotli). Check to see what type of compression the CDN uses (by looking for the content-encoding header.Three things to add (in addition to what chip points out): they are used on a single page and I don't want to load them everywhere) in this situation, using a CDN is probably better than loading them locally, hence my question. I usually use npm to download scripts into my dev environment and pack them in a single bundle but there are times when I want to keep one or more of those scripts non bundled (i.e. The first thing that comes into my mind is that there could be differences in how fast they are and how much they are used (so, if I use the one with the largest market share, I will be more likely to have my users already have the libraries in their browser's cache), but I'm not sure it this is just being nitpicky or if these reasonings are legitimate.Īlso, once I pick a CDN to load a script, are there valid reasons to always use the same for other scripts as well? BootstrapCDN, cdnjs, unpkg, jsDelivr and possibly others) but I don't understand when sould I use one over the others.Īs an example, examples in Bootstrap documentation show BootstrapCDN and jsDelivr, while aos's docs use unpkg, and so on. What kind of reasoning should I do in order to choose a specific CDN to load Javascript & CSS libraries into my website development projects?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |