escaping semicolons in scripts
-
In the following script files:
scrollTo.js
mailchimp.jsThere is a semicolon at the beginning
;(function($) {
and
;(function(d) {
respectively. I understand the purpose of doing this is to avoid concatenation to preceding scripts or with your preceding ajax call. However, it is causing conflict with other plugins. I am not sure why, but I think it is related to a jQuery shortcut conflict.
Besides, you should probably use wrap your code in:
jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function });
since there is no reason to have your code running before DOM is ready. (unless the user can fill out your form really really fast)
here is the wordpress standards:
http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappersIf everybody uses these, we’ll all be fine.
I spent hours looking for the dreaded ‘;’. With debugging software, I haven’t had to do that for about 15 years. Usually it was because it was missing, but not in this case ;o)
The plugin it conflicted with was superfish, and one of my own.
- The topic ‘escaping semicolons in scripts’ is closed to new replies.