jqueryjsfiddle

External resources in JSFiddle not working


I want to ask a question about jquery menu aim, then I have to put my code in jsfiddle with some external resources. I did this but it didn't work. Could any one tell what's wrong here?


Solution

  • You're linking to the github pages that display those files not the actual files that live on github. No, github isn't a CDN but it can absolutely be used to serve files.

    As an example, try changing:
    https://github.com/kamens/jQuery-menu-aim/blob/master/jquery.menu-aim.js
    to
    https://raw2.github.com/kamens/jQuery-menu-aim/master/jquery.menu-aim.js

    and
    https://github.com/kamens/jQuery-menu-aim/blob/master/example/css/bootstrap-responsive.css
    to
    https://raw2.github.com/kamens/jQuery-menu-aim/master/example/css/bootstrap-responsive.css

    There are some issues with linking to files directly on github. Namely, everything is served as text/plain. As an alternative, you can use the http://rawgithub.com/ service. So the jQuery Menu link would become:
    http://rawgithub.com/kamens/jQuery-menu-aim/master/jquery.menu-aim.js

    Updated fiddle pointing at the correct github URLs: http://jsfiddle.net/X8w5M/12/

    EDIT:
    Note that the bootstrap CSS doesn't work in that fiddle because fiddle expects CSS to be served as text/css. Changing the bootstrap CSS link to http://rawgithub.com/kamens/jQuery-menu-aim/master/example/css/bootstrap.css brings it back to life.

    EDIT 2
    Here's a working fiddle with using rawgithub to serve the CSS and github to serve the JS. http://jsfiddle.net/X8w5M/18/