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?

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>
| improve this answer | |
  • Yep, thanks, I'm using noConflict and the min file and still I get the same result. – Airton Gessner Feb 5 '15 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 Feb 5 '15 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. – Airton Gessner Feb 5 '15 at 20:05
  • That's what I found so far success.salesforce.com/ideaView?id=08730000000KRuxAAG – Airton Gessner Feb 6 '15 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) – Airton Gessner Feb 6 '15 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.