Jump to content

The processwire repository as a host of js libraries


blad
 Share

Recommended Posts

Hello again!

I use external libraries in my sites (in the backend and frontend) almost all traffic to my website was in those files.

I changed the modules jquery, jqueryui, fancybox, etc ...

$this>config>scripts->add("https://raw.githubusercontent.com/ryancramerdesign/ProcessWire/dev/wire/modules/Jquery/JqueryUI/JqueryUI.js");
 

Will I have any problems doing this?

Link to comment
Share on other sites

I think the problem with that approach is that you won't get the local caching benefit of using the Google CDN, because no other visitors to your site will have those files cached from the PW git repo.

I would suggest either using a well known CDN (eg google), or use the local version from your PW install - afterall, those files are already on your server. I would however use the excellent AIOM module on them.

I am no expert in this area, but hope that helps.

  • Like 1
Link to comment
Share on other sites

I have researched and the findings are:

- The first time you visit the page all the files are downloaded. Obvious.

post-2447-0-68981000-1409939123_thumb.pn

- The second time is re-downloaded the file from github.

post-2447-0-63254000-1409939255_thumb.pn

The cause ... github file expires in five minutes

post-2447-0-22736800-1409939371_thumb.pn

Google files expires in a year

post-2447-0-90830100-1409939368_thumb.pn

cdnjs.com expires in 355 days. You're right, if you use a good hosted libraries is a good solution.

Link to comment
Share on other sites

I've read that jQuery on the google cdn is the most used & cached file on the net. So it's not rare that the guest already has that version in browser cache. For jQuery as it is relative big it makes sense to use that cdn. I do love the HTML5 boilerplate trick to get that version.

So far I understand, there is a max of simultaneous downloads of assets from the same subdomain. If you could spread the load to more locations, even if it is an other subdomain, more simultaneous downloads are allowed. I have never tested this.

Edited by Martijn Geerts
simultaneous downloads & didn't read Adrian message well enough
  • Like 1
Link to comment
Share on other sites

So it's not rare that the guest already has that version in browser cache. For jQuery as it is relative big it makes sense to use that cdn.

Exactly my point (maybe I wasn't clear) - use a commonly used CDN like google, rather than github, which is rarely used for this purpose (especially when linking to a version in the PW repo).

Link to comment
Share on other sites

 Share

×
×
  • Create New...