views:

15

answers:

1

I wonder what's the best approach for using third party js libraries on a control library.

If the library uses (let's say) jquery and jquery-ui seems wrong to me to include those on the control library since, if the page using the controls already reference them, they will downloaded twice (the embedded version and the non-embedded version).

On the other side, seems wrong to me to not include them and see how everything fails because the libraries are not referenced.

I could very explicitly specify which js libraries must be referenced for using the controls but not sure if this is the correct approach.

What do you suggest in this case?

+2  A: 

I think my concerns with having them embedded in the library would be:

  1. What happens when, as you say, the page already references jQuery? What if the page is referencing a different version of jQuery to the one you've embedded? Which jQuery instance gets used when some script runs?
  2. Suppose a security exploit is discovered in the library you've shipped - what then? Would you need to ship a new version of your control?

I think it would be better for you to say up-front 'this control requires version x of jQuery and version y of jQuery-UI'.

PhilPursglove
I think the same. Thanks for your answer!
Timmy O' Tool
(if no one else post anything else I'll mark your post as the answer, I wish I could read different points of views)
Timmy O' Tool
@Timmy It's an interesting question and I think you could make a case either way, but for me the case against outweighs the case for.
PhilPursglove
(I've added the `jquery` tag to see if anyone who's a jQuery expert wants to weigh in on it)
PhilPursglove
Thanks, we'll see :)
Timmy O' Tool