web icon indicating copy to clipboard operation
web copied to clipboard

use local copy of jquery-min

Open richsalz opened this issue 4 years ago • 4 comments

inc/head.shtml, which is included by just about every file on the site, has these lines

<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="./inc/libs/jquery-3.5.1.min.js"%3E%3C/script%3E'))</script>

You should replace them with this single line:

<script src="/inc/libs/jquery-3.5.1.min.js"></script>

This will use the cached script and not go to a central site to download a file that is, well, already on your site. :)

ping @levitte

richsalz avatar Jan 25 '21 13:01 richsalz

There are quite different views on this. For example, one might consider browser caches, and https://jquery.com/download/#using-jquery-with-a-cdn :

... This also offers an advantage that if the visitor to your webpage has already downloaded a copy of jQuery from the same CDN, it won't have to be re-downloaded.

levitte avatar Jan 25 '21 13:01 levitte

Most of that page is not relevant because you're using the minimized version, you're pinning to a particular version, and you are already using a CDN.

You do know who I work for, right? :)

richsalz avatar Jan 25 '21 13:01 richsalz

I know who you work for. However, if a browser sees a reference to code.jquery.com and another to www.openssl.org, it will load it twice, even if pinned on the same version. Nothing of what you said contradicts that.

levitte avatar Jan 25 '21 22:01 levitte

I know who you work for. However, if a browser sees a reference to code.jquery.com and another to www.openssl.org, it will load it twice, even if pinned on the same version. Nothing of what you said contradicts that.

Even if the link is the same, the browsers now separate the cache by origin so it will be loaded twice.

Shrug. A minor optimization. Feel fee to close if you disagree (but you're wrong :)

richsalz avatar Jan 25 '21 23:01 richsalz