Changes between Version 1 and Version 2 of Ticket #45130, comment 2
- Timestamp:
- 10/23/2018 07:22:02 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #45130, comment 2
v1 v2 20 20 21 21 22 It is also good practice to put all the scripts into the footer, I understand that this has been discussed before. Even when the team decides not to, it's best to use document ready, otherwise everything breaks if jQuery has been placed in the footer. If a theme developer decides to put jQuery in the footer in his or her theme. In this case, we would preface the anonymousfunction with a document ready function as seen below:22 It is also good practice to put all the scripts into the footer, I understand that this has been discussed before. Even when the team decides not to, it's best to use document ready, otherwise everything breaks if jQuery has been placed in the footer. If a theme developer decides to put jQuery in the footer in his or her theme. In this case, we would preface the function with a document ready function as seen below: 23 23 24 24 {{{ 25 25 jQuery(document).ready(function($) { 26 // Your jQuery code 26 // $ Works! You can test it with next line if you like 27 // console.log($); 27 28 }); 28 29 }}} … … 30 31 I think using document ready is always a good thing to do, even if you put your code in the header. 31 32 33 34 This is also possible, but it will defeat the purpose of using jQuery noConflict mode: 35 36 {{{ 37 var $ = jQuery.noConflict(); 38 39 $( ".whatever" ).hide(); 40 }}}