Skip to main content

Suppose I have two snippets with the same name.

(please hold all the WHY WOULD YOU EVER DO THAT!?! comments…  if the answer is favorable this will save a lot of time)

One snippet is on page, another is in a static resource.

Which will run first?

Does it depend on the order that they are entered in the builder?

Matt~

In line snippet wins in a race against static resources.

Thanks!
Karen


Sweet. Thanks!


Matt -

FYI on this issue that I posted about a month ago https://community.skuid.com/t/resources-not-emitted-in-order-specified?rfm=1&topic_su….  

I’m still waiting on a reply but as I mention in the issue, the order specified in the builder SHOULD matter - but instead it behaves like “it depends” currently and its not documented.  As Karen mentions, I believe inline snippets will always get loaded after static resources with the current functionality.  That said, being able to specify order (in order to reliably predict) the exact order things will load is critical to proper functioning - especially when you might need to do something in an inline snippet that a static resource then relies on (which wouldn’t even be possible today).

Short story - Keep an eye out on the other thread just in case anything changes (which it should IMHO:)).


Oh yeah, forgot to ask - WHY WOULD YOU EVER DO THAT? 😉


Thanks, Barry. I’ll keep an eye out. I’m deploying an app to multiple customers who may need to customize some of the javascript functionality, and I’m trying to make it as modular as possible. In the current scenario, they can write their own inline snippet to override the stock functionality that I deploy in a static resource by using the same snippet name. Then if I deploy an update to the stock resource it won’t override their customization.


hahahahahahahhahahaa


That’s a good reason (better than I expected :p)


Hey Matt - I was just kidding with that question 🙂  I could see reasons you would want to do this (e.g. a “derived” customization of base functionality).  Fortunately, even if the order resources are loaded changes (per the other post I linked to), your approach will still work as long as the customers snippet comes after the SR that you provided for them.  Pretty cool way to provide flexibility to your customers!


Ok, followup to this:

Suppose I have two snippets with the same name. One is in the ModuleJS static resource that skuid pulls in to all pages in that module. The other is in a static resource that’s added declaratively to the page.

Which wins?


Matt~

Sorry for the delayed response. The static resource added declaratively to the page wins. 

Karen


Thanks, Karen.


Ok, another question in this vein…

Two snippets with the same name, in different static resources added declaritively to the page. If I am correctly understanding Barry’s post here, the static resources are currently being loaded in the order that they are entered in the builder?

But what does that mean in this use case? Does the snippet in the first static resource win, or in the second?

Thanks!


Matt~

So what ever is evaluated last wins when it comes to name conflicts.

Thanks!
Karen