13

What is the url to get and only get this fiddle's javascript code ?

So later on, I may use it for tests by calling it using a <script rel="" src=""></script> link, something like :

<script rel="script" src="http://jsfiddle.net/.../.../myFiddleScrip.js"></script>

JSfiddle store versions of our scripts, which my IDE doesn't.


Edit: I'am aware of the /show/ page, my question is is there an independant .js page ?


Edit: As of March 2013, the following patterns works! (pls +1 Danny's answer!)

Hugolpz
  • 17,296
  • 26
  • 100
  • 187
  • ^^ @user1479606 .. I could see how this would be very handy during development --> IE you create the Fiddle, make sure it works, and "test it" on your server's environment without having to upload. ... Although I think the script for Fiddle is inline ... ++ For the idea though .. – Zak Mar 27 '13 at 17:10
  • Exactly. And JSfiddle store versions of your script, which my IDE doesn't. – Hugolpz Mar 27 '13 at 17:11
  • 1
    I think this isn't possible intentionally as it's not meant as a versioned file-host service, so if there were some way to do it cleanly they'd likely disable it on purpose. So it's not recommended to waste time trying, but if you really want to you could try to GET the source, extract the js inside the script tags, and then eval it...but it's probably definately not the recommmended way to do it. I'd strongly suggest looking into file versioning systems and IDE extensions instead, of which there are many free and premium choices. – BrianH Mar 27 '13 at 17:17
  • Get a local git repo. – Colin DeClue Mar 27 '13 at 17:55
  • I just started JS, not yet ready to manage Git, but coming. – Hugolpz Mar 27 '13 at 17:56
  • the latest Edit gives 404 errors for show_js, show_css, and show_html – vwvan Aug 28 '19 at 04:15
  • 1
    **october 2019: options do not work** – Danny '365CSI' Engelman Oct 14 '19 at 11:35

3 Answers3

9

It looks like you can add it to your page with the following:

<script type="text/javascript" src="http://jsfiddle.net/hugolpz/QUTcW/37/show_js/"></script>

However that url doesn't look to be officially documented and may change. More info here

Danny
  • 7,368
  • 8
  • 46
  • 70
  • Exactly what I was asking for! +1, +1, +1 ! – Hugolpz Mar 27 '13 at 17:49
  • Oh, bad point: JSfiddle "external ressource" doesn't accept */show_js/ or */show_css/, sooooo sad! – Hugolpz Mar 27 '13 at 22:14
  • @Hugolpz [see this](http://iadil.bugs3.com/test/fiddle.html) .. you need to create this kind of url `fiddle.jshell.net/hugolpz/QUTcW/37/show/` ... you will get link to your js file.... – Adil Shaikh Mar 28 '13 at 07:47
  • @Hugolpz can't you just copy the external resources urls from the fiddle? – Danny Mar 28 '13 at 12:09
  • My final aim is to work on several html fiddle-pages, while I gather all my js & css in one central fiddle. By doing so I will avoid code/css duplication. Troubles are : jsfiddle's html panel block ``, and the "external resources" field decline to load "http://jsfiddle.net/hugolpz/QUTcW/37/show_js/ even with ~/?file=.js . See http://jsfiddle.net/JZYd5/3/ (fails) – Hugolpz Mar 28 '13 at 12:18
  • 1
    @Hugolpz weird. It looks like the css and js resources are getting added `` and `` but don't look to work. Not really sure what is going on there... – Danny Mar 28 '13 at 12:51
  • In June 2012, JSfiddle creator Zalum [wrote](https://github.com/jsfiddle/jsfiddle-issues/issues/180#issuecomment-5817729) *"this is not documented as we don't want to keep the promise it will exist in beta"*. 'This' being the /show_js/?file=.js hack. Wonder if they have blocked it in order to create a paid service later on. ;( – Hugolpz Mar 28 '13 at 12:59
  • Note: Being blocked, I [asked on Github the current status of this hack](https://github.com/jsfiddle/jsfiddle-issues/issues/360). – Hugolpz Mar 28 '13 at 13:07
6

see this : view-source:http://fiddle.jshell.net/hugolpz/QUTcW/37/show/

They do not create separate .js file , they just put your script in script tags

Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
  • I noticed that. But I wonder if anyone is aware of separated url. – Hugolpz Mar 27 '13 at 17:09
  • I don't think that anyone can get link to inline script like that – Adil Shaikh Mar 27 '13 at 17:12
  • This doesn't appear to be possible. Maybe a Gist would be more appropriate, as they could easily be pushed to a jsfiddle. – Kevin B Mar 27 '13 at 17:25
  • @Mohammad: Funny how you created [this tool](http://iadil.bugs3.com/test/fiddle.html) in a glance. As I said upper, I'am exploring the direction of adding a JSfiddle's "external ressource" a `jsfiddle.net/{user}/{slug}/{revision_number}/show_js/?file=.js`, but doesn't works. I increasingly think they are blocking this possibility. – Hugolpz Mar 28 '13 at 13:12
  • @Hugolpz I created that just out of curiosity..... that tool will provide you link to js which you can use as external js resource.... http://goo.gl/MAQin this is link to your fiddle's javascript source.. – Adil Shaikh Mar 28 '13 at 13:30
  • Interesting : a [fiddle](http://jsfiddle.net/N4N9c/1/) with [Mohammad's link](http://iadil.bugs3.com/test/getJs.php?url=http://jsfiddle.net/9y4MG/show/?file=.js) with ?file=.js hack works. Seems the Mohammad's js code is differently structured compare to http://jsfiddle.net/9y4MG/show_js/ . Or maybe your domain name not being jsfiddle, it bypass the block. @Mohammad: please soften your code or later on duplicate it so Css can wor as well :) – Hugolpz Mar 28 '13 at 13:45
0

Edit: new solution by Danny is far easier !


From BrianDHall's comment emerge this heavy direction

  1. To GET the source http://jsfiddle.net/userName/CODE/DD/
  2. get the js panels's content (something like: $('textarea#id_code_js').value() ),
  3. clean it up and use it.

To explore further if you are interested.

If you are fluent in JS, feel free to share a script solving this question. I will valid it.

Hugolpz
  • 17,296
  • 26
  • 100
  • 187