Load scripts after jQuery - General Discussions - General Discussions - Progress Community
 General Discussions

Load scripts after jQuery

  • Load scripts after jQuery
  • Is it possible to load scripts that depend on jQuery after jQuery itself loads?  Or is it possible to short-circuit sitefinity's reference to jQuery and load my own?

    I've tried just about everything.  Seems like this should be pretty easy but I am probably just missing something.

  • Hi Bryan,

    You can use JavaScriptEmbedControl.

    ScriptEmbedPosition- Specifies where to embed the script - head tag, in place or before the closing body tag
    Url - Gets or sets the URL of the script file
    CustomJavaScriptCode - Custom java script code
    LayoutTemplateName - Gets the name of the embedded layout template.

    Another option is to create your own control where you use
    RegisterClientScriptBlock and check for IsClientScriptBlockRegistered before adding some dependent scripts on a page.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Thanks Ivan,

    That was the approach I took earlier.  The problem I ran into was that sitefinity used my fully qualified local host address in the javascript src so when I move the application to my staging server the references break.  Perhaps a suggestion could be offer a checkbox in the properties of the JavaScriptEmbedControl indicating whether to use a path relative to the application root.  Or even allow the "~" to indicate that the location is relative to the application root (because I did try this approach and, well...).

    Thanks for your help.
  • Problem with this for years now. Solution is to embed scripts into dll, due to load order.

    But please think about it: 2019 soon JQuery is base plugin for many web components, and we still not able to easily include a simple script on the server without embed it or make or custom component.

    use jQuery and add <script src="/myTestScript" /> is the base you see in all tutorials in all components based on it.

    It should be easier to test or include some file afetr it.

    Please you really need to fix that behavior.

  • A precision about the JavaScriptEmbedControl, you can't use this in a widget, if you add 2 widget in same page your script will be executed twice.