-
Notifications
You must be signed in to change notification settings - Fork 0
Use jQuery from CDN #14
Comments
I'll try to give it a look tomorrow, this cdn problem has some interest for me and the fallack is brilliant. |
Ok, having a look at this, it seems that the fallback would work nicely for jQuery lib but I have no clue about how to make it work for jquery-ui for example of for the css... So what I did is that if we fail to load jQuery from CDN then I assume either CDN is down or we are offline, so i serve everything normally loaded from CDN. |
The following loading behaviour is implemented : we try to load everything from CDN, if we fail to load jQuery from CDN, we assume either CDN is down or we are working offline. In this case, we serve all of the librairies directly.
Nice ! A few answers to your comments :
I'll reopen the issue so that we don't forget doing it :) |
|
And here it is.
@tsimbalar I let you close the issue if you think it's good enough now, so the code is reviewed. |
Nice ! |
Ouch, I get a javascript Security error in Firefox when not connected to internet. The part that fails is when trying to access to the rules of a CSS file that comes from a domain other than the current host. The javascript error makes all the subsequent js calls fail, and therefore, some other js libs are not loaded ... Crap :-/ While investigating, I found yepnope which is a "resource loader". Looks like it knows how to retrieve both javascript and css with fallbacks. It may also be useful in the future when we try to support browsers that don't have native implementations of all the features we need (for instance websockets ... ). Also, it supports parallel loading of the files, and guarantees the order of execution. Sorry, I have to reopen it :-/ |
no time to look at it right now... I'll check later in the week. |
no problem, no emergency :) . Maybe I'll have a look at it if time permits. |
* Google CDN still not offering the version we want... using microsoft CDN for now * removed the css fallback that does not work too well ... to be improved with yepnope or something like that ...
* oops, referenced wrong version of jQuery ... and it breaks the app :-/
* use CDNs + minimized js when running in prod mode * use unminimized js when running in dev mode Note : ">play run" starts in "dev" mode while ">play start" starts in "prod" mode. (see https://github.com/playframework/Play20/wiki/Production) To test the prod mode on your machine, execute : >play -DapplyEvolutions.default=true start
We should reference the jQuery and jQuery UI libraries from a Content Delivery Network (for instance Google : https://developers.google.com/speed/libraries/devguide ) so that users can benefit from browser caching (they may have those libs in their cache already) and do not impact our server resources unnecessarily.
We should offer a fallback for when we are working locally and offline though : see http://css-tricks.com/snippets/jquery/fallback-for-cdn-hosted-jquery/
For other js libraries that wouldn't be hosted by Google, see : http://www.cdnjs.com/
The text was updated successfully, but these errors were encountered: