JSfiddle: What is my fiddle's javascript (*.js) url ? so I can reuse it by src
Asked Answered
F

4

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!)

Freestone answered 27/3, 2013 at 17:4 Comment(7)
^^ @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 ..Heartbroken
Exactly. And JSfiddle store versions of your script, which my IDE doesn't.Freestone
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.Discommode
Get a local git repo.Pony
I just started JS, not yet ready to manage Git, but coming.Freestone
the latest Edit gives 404 errors for show_js, show_css, and show_htmlHomogeneity
october 2019: options do not workUppermost
Z
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

Zellazelle answered 27/3, 2013 at 17:47 Comment(8)
Exactly what I was asking for! +1, +1, +1 !Freestone
Oh, bad point: JSfiddle "external ressource" doesn't accept */show_js/ or */show_css/, sooooo sad!Freestone
@Freestone see this .. you need to create this kind of url fiddle.jshell.net/hugolpz/QUTcW/37/show/ ... you will get link to your js file....Haggadist
@Freestone can't you just copy the external resources urls from the fiddle?Zellazelle
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 <script type="text/javascript" src="http://jsfiddle.net/hugolpz/QUTcW/37/show_js/"></script>, and the "external resources" field decline to load "jsfiddle.net/hugolpz/QUTcW/37/show_js even with ~/?file=.js . See jsfiddle.net/JZYd5/3 (fails)Freestone
@Freestone weird. It looks like the css and js resources are getting added <script type="text/javascript" src="http://jsfiddle.net/9y4MG/show_js/?type=.js"></script> and <link rel="stylesheet" type="text/css" href="http://jsfiddle.net/9y4MG/show_css/?type=.css"> but don't look to work. Not really sure what is going on there...Zellazelle
In June 2012, JSfiddle creator Zalum wrote "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. ;(Freestone
Note: Being blocked, I asked on Github the current status of this hack.Freestone
H
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

Haggadist answered 27/3, 2013 at 17:8 Comment(6)
I noticed that. But I wonder if anyone is aware of separated url.Freestone
I don't think that anyone can get link to inline script like thatHaggadist
This doesn't appear to be possible. Maybe a Gist would be more appropriate, as they could easily be pushed to a jsfiddle.Kearse
@Mohammad: Funny how you created this tool 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.Freestone
@Freestone I created that just out of curiosity..... that tool will provide you link to js which you can use as external js resource.... goo.gl/MAQin this is link to your fiddle's javascript source..Haggadist
Interesting : a fiddle with Mohammad's link with ?file=.js hack works. Seems the Mohammad's js code is differently structured compare to 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 :)Freestone
F
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.

Freestone answered 27/3, 2013 at 17:43 Comment(0)
R
-1

The following seems to work, too:

<script type="text/javascript" src="./"></script>
Rinarinaldi answered 4/5 at 10:20 Comment(1)
I think you may have misunderstood the question. If you put that on a page on yoursite.com it will not load a JSFiddle JS file for you.Androcles

© 2022 - 2024 — McMap. All rights reserved.