What is the “right” way to use YUI3 with HTTPS?

♀尐吖头ヾ 提交于 2019-12-07 11:43:32

问题


I have a lot of experience with YUI2 and I'm getting up to speed on YUI3. The service I'm writing needs HTTPS, but the vanilla YUI experience loads from Yahoo's HTTP-only CDN, which quietly fails in Chrome and loudly fails in modern IE when the browser tries to mix an HTTPS page with HTTP javascript.

My goals are to get all of:

  1. Site uses HTTPS
  2. YUI works in Chrome & IE (so scripts also must be delivered over SSL)
  3. Uses a modern version of YUI 3 (this disqualifies YUI PHP Loader which hasn't been updated to support even YUI 3.4, while 3.8 is "current")
  4. Use roll up combos for speed instead of many JS and CSS files (this disqualifies Google's CDN... if YUI 3 is actually hosted there which I couldn't find.)
  5. Site dynamically loads YUI dependencies (dependencies change regularly as I add functionality, going back to the configurator and saving a new bundle every time is a PITA)

The obvious solution appears to be to give up goal #5 and just self-host combos.

How can I meet all 5 goals?


回答1:


The easiest way to solve it is to change base URL from
http://yui.yahooapis.com/ to
https://yui-s.yahooapis.com/




回答2:


Depending upon your server environment, you have a couple of options.

Development

  • Download the latest YUI library, and upload the yui/build/ folder to your server. The seed file should work fine without modification, though you won't be able to take advantage of combo loading.

Production

  • Use the YUI Configurator to determine all the files that you will need for each module set, and download them manually from the combo links provided. Rename them to something suitable like yui3.8.0-node-rollup.js and serve these to your users.

Be advised that if you use different module sets for different scripts, you may need to make multiple sets of files from this process, depending upon how you set it up. There is also a question here about concatenating Javascript together, if you are curious.


As an addendum, in my past research, I discovered that pulling external libraries over a secure connection may not be a safe idea.



来源:https://stackoverflow.com/questions/14267371/what-is-the-right-way-to-use-yui3-with-https

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!