How to use jQuery / Javascript with 5.1 MVC widgets

Posted by Community Admin on 03-Aug-2018 21:26

How to use jQuery / Javascript with 5.1 MVC widgets

All Replies

Posted by Community Admin on 18-Jul-2012 00:00

How do I include jQuery or a Javascript file with a Sitefinity 5.1 MVC widget? Is there any way to ensure that it wasn't already loaded before in the parent template?

Granted it is super easy to add a script tag in an MVC view and load jQuery (or any JavaScript library), but how do I know that it hasn't already been done in the parent template or another widget? Is there some type of script manager for MVC? or... do I just need to set a best practice and load all my global JavaScript files in the parent template and then trust it is there from within my widgets?

Frankly jQuery is the easiest one to manage as I can load that in the parent template. But if I need custom JS for a given MVC widget, how will I know it wasn't already loaded by a copy of the same widget on a page?

Posted by Community Admin on 18-Jul-2012 00:00

...forgot to think outside the (Sitefinity) box. I suppose, I could just use YepNope as a conditional JavaScript & CSS file loader in my MVC widgets. It will probably be easier than it has ever been.

This thread is closed