0

I have a custom button (which is a list button) and I'm requiring JQuery by the following code:

{!REQUIRESCRIPT("//code.jquery.com/jquery-1.10.2.js")}

It's working fine! The only problem is that it's taking too long to execute. If I click on the button right after the page is loaded, it doesn't run and I have to click again. The other standard Salesforce buttons work just as fast as when I do not require JQuery for the custom ones.

Does anyone know if there is a faster way to get JQuery?

1 Answer 1

2

I would start by adding the minimized version of jQuery as a local resource and then make sure to set jQuery.noConflict();

Something like this:

 <script src="{!URLFOR($Resource.jQueryFiles, 'js/jquery-1.10.2.min.js')}"/>

<script type="text/javascript">
   var j$ = jQuery.noConflict();
   j$(document).ready(function(){
            //document ready code
   });
</script>
5
  • Yep, thanks, I'm using noConflict and the min file and still I get the same result. Commented Feb 5, 2015 at 18:31
  • Have you loaded jQuery as a local resource? Also, use something like firebug to see how long each resource is taking to load.
    – TC Sutton
    Commented Feb 5, 2015 at 19:04
  • Hi, I tried to load it as a local resource but I coudn't get it to work, it says that $Resource is not available. Commented Feb 5, 2015 at 20:05
  • That's what I found so far success.salesforce.com/ideaView?id=08730000000KRuxAAG Commented Feb 6, 2015 at 11:22
  • Also, I realized that Salesforce already imports jQuery, therefore I could use it without calling mine (what is not a good practice, by the way) Commented Feb 6, 2015 at 11:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .