5

When using the 'external library' function in Code Snippets, the files are stacking up backwards, where the last file is placed on top of the previous one. The JavaScript framework pulldowns do the same thing.

You're logically going down the list and adding things...

  1. Select jQuery version from the pull down.
  2. Use 'external library' link to add jQuery plugin #1.
  3. Use 'external library' link to add jQuery plugin #2 (depends on plugin #1).

... this is what you'll get...

<script src="plugin_2.js"></script>
<script src="plugin_1.js"></script>
<script src="jquery.min.js"></script>

... completely upside down from how you really wanted them stacked. (Note that when using jsFiddle, 'External Resources' are stacked exactly in the same order as you enter them.)

I sometimes find myself forgetting that I need to think backwards and then end up doing some cutting and pasting. Not a big deal, but this is another little thing that makes using jsFiddle somewhat easier and more intuitive.

Verified in Chrome, Firefox and Safari.

16
  • But jsFiddle does not add the <script> into the html view, stack snippets do. The system will have a hard time figuring out where to insert the next reference if it can't just insert at the top.
    – gunr2171
    Nov 11, 2014 at 17:38
  • As someone who is beginning to use more and more javascript, I imagine this is a nightmare.
    – Joe
    Nov 11, 2014 at 17:46
  • 1
    @gunr2171, I appreciate the technical differences with jsFiddle, however, this issue can be a pain to work with after adding a bunch of scripts in the wrong order. Why can't it just insert after the last occurrence of </script>?
    – Sparky
    Nov 11, 2014 at 18:01
  • What if that last occurrence is at the bottom or middle of your code? I'd imagine there would be a lot of edge cases to worry about.
    – gunr2171
    Nov 11, 2014 at 18:02
  • 2
    @gunr2171, No matter how you do it, something like this will have edge cases and ways to break it. IMO, don't worry about a few edge cases when 99.9% of users have to deal with upside down file stacking.
    – Sparky
    Nov 11, 2014 at 18:04
  • 2
    @gunr2171, until one of the SO mods or developers explains why it's doing something illogical and counter-intuitive, it's a bug.
    – Sparky
    Nov 11, 2014 at 18:10
  • 2
    I think @gunr2171 has got the wrong idea here, it's not the positioning of the script tags, it's the order.
    – Joe
    Nov 11, 2014 at 18:14
  • @Joe, you need to know the position of the script tags to be able to make the order correct.
    – gunr2171
    Nov 11, 2014 at 18:15
  • 2
    @gunr2171 .. no? You place them in one block, ordered the same as they are when you add them. The first reference I add, should be at the top of the block, second reference, below that, etc.
    – Joe
    Nov 11, 2014 at 18:17
  • That only works if all the external references are the first lines of the html code. As soon as you put your scripts inside your code this will break.
    – gunr2171
    Nov 11, 2014 at 18:18
  • @gunr2171, Not if you're only looking for the last occurrence of a </script> tag that immediately comes after a <script> tag containing a src attribute.
    – Sparky
    Nov 11, 2014 at 18:20
  • 2
    ... you realise that the issue being reported here is the order is reversed, right? Positioning of the script elements is largely irrelevant, the order is not.
    – Joe
    Nov 11, 2014 at 18:20
  • @Joe, I understand what's going on. If you assume that all external references are at a block at the very beginning of the html code, then sure, the system can add a line at the end of the block. But I'm done arguing this.
    – gunr2171
    Nov 11, 2014 at 18:23
  • @gunr2171, in this case, the only time it's not going to be in a block at the beginning is when you manually move it elsewhere. In that case, you're doing it manually and any "automatic" file insertion is irrelevant since you've decided to over-ride the feature.
    – Sparky
    Nov 11, 2014 at 18:38
  • 1
    This is very irritating issue and can be fixed very easily, something like $("script:last").append() ..? I wonder why this is being ignored or taking so much time for status completion.
    – T J
    Dec 13, 2014 at 14:15

0

You must log in to answer this question.

Browse other questions tagged .