JS Errors Within Console

Post

Posted
Rating:
#4598 (In Topic #927)
Joe
I noticed a few errors on my site today, not sure if it's something I did wrong but I can't seem to figure out what's causing these issues. All I can say is that using my site in safe mode fixes the issue, so I'm going to assume it's a template issue. I cross referenced custom templates with default ones for hours, and I have no clue where the issues lie.

This one appears globally throughout the site:

Code

TypeError: all_e[i].className.indexOf is not a function[Learn More] staff_ssl.js:14:66
   script_load_stuff_staff <mybaseurl>/themes/intro/templates_cached/EN/staff_ssl.js:14:66
   script_load_stuff <mybaseurl>/themes/intro/templates_cached/EN/global_ssl.js:35:340
   <anonymous> <mybaseurl>/:1853:9

This error came from my console and shows in topicview of the forums:

Code

TypeError: $(...).sew is not a function[Learn More] script.php:46:34
   set_up_comcode_autocomplete <mybaseurl>/data/script.php:46:34
   <anonymous> <mybaseurl>/forum/index.php:2320:3

This one is the same as the previous one above, except this one is from Composr:

Code

46: TypeError: $(...).sew is not a function
<mybaseurl>/themes/island/templates_cached/EN/jquery_autocomplete_ssl.js?1535498189

Another one that shows in the console in topicview:

Code

Content Security Policy: The page’s settings observed the loading of a resource at self (“script-src”). A CSP report is being sent. Source: onclick attribute on A element. fastbutton


Any insights would be appreciated! Thanks!

Post

Posted
Rating:
#4599
I've attempted to resolve them in this commit:
https://github.com/ocproducts/composr/commit/a634e6c79a6fa1c1f8190ed94453b2327eb8faa0

Post

Posted
Rating:
#4616
Joe
Edit: the errors are all still present.

Edit2: I'm getting an additional error when making selections in the page rendering tool (i.e. 'templates'):

1: ReferenceError: staff_actions_change is not defined

Edit 3: I've noticed the above error regarding staff_actions_change only appears when viewing a missing resource.

According to GLOBAL_HTML_WRAP, the 'Staff Actions' feature only shows if these are all true:
  • {$NOT,{$MOBILE}}
  • IF_NON_EMPTY,{$STAFF_ACTIONS}
  • {$CONFIG_OPTION,show_staff_page_actions}

If this feature shouldn't be available when viewing non-existent resources, maybe add another directive to GLOBAL_HTML_WRAP to hide visibility or make {$STAFF_ACTIONS} EMPTY?

Last edit: by Joe

Post

Posted
Rating:
#4620
I can't reproduce any of this I'm afraid. However, if you can email me ([email protected]) an admin account for the site I can try and work through it.

Post

Posted
Rating:
#4622
Joe
Email sent. I was going to attach this screenshot to the email but forgot.

jserrors.png

Post

Posted
Rating:
#4624
all_e[i].className.indexOf - fixed. I think it was due to the larger number of custom JS scripts on your site slowing JS loading down.

$(...).sew - fixed. 3 versions of jQuery were used on your site. I have commented out from HTML_HEAD.tpl and GLOBAL_HTML_WRAP.tpl in your theme, and I've forced Composr's bundled jQuery to always load instead.
I can't guarantee that whatever jQuery plugins you've used are compatible with ours (1.8.3), in which case you'd need to go much deeper somehow because I don't think the jQuery plugins we use out of the box will be compatible with a newer jQuery.

Content Security Policy - this will be coming from 3rd party servers, probably where you're loading JS files from.

ReferenceError: staff_actions_change is not defined - I think you just need to wait a while until all JS scripts are loaded and parsed. I could not reproduce, but I know the aforementioned situation would cause it. In v11 all our JS is going to be in .js files so this situation could not happen (instead JS interactions would not be available until the JS files load).

Post

Posted
Rating:
#4626
Joe
Thanks Chris :thumbs:

I honestly had no idea I had 3 versions of jQuery running! My problem is, I'm always adding and removing stuff, and I don't always completely remove traces of things I don't keep. I'll just go through the HEAD section and remove some old scripts (I've noticed a few more that I don't even use).

I'll try out the bundled version of jQuery; hopefully I don't have issues. If I do, can you say for certain that Composr's plugins aren't compatible with newer versions of jQuery, or could I try swapping it out and see how things go?

If you're not certain:
  • What is the location of Composr's bundled jQuery file?
  • What Composr modules/addons/plugins utilize this? (so I can experiment)

Again, I'll only attempt that if you aren't certain about it and only if I have any problems running my plugins.

Thanks again Chris.

Post

Posted
Rating:
#4627
I'll try out the bundled version of jQuery; hopefully I don't have issues. If I do, can you say for certain that Composr's plugins aren't compatible with newer versions of jQuery, or could I try swapping it out and see how things go?

If you're not certain:
What is the location of Composr's bundled jQuery file?
What Composr modules/addons/plugins utilize this? (so I can experiment)

themes/javascript/

jquery.js

I'm 70% sure it'd be an issue.
jquery_ui.js - this is a heavyweight used in a few places
jquery_autocomplete.js - this is our code built around the jQuery 'sew' addon
select2.js - this is for fancy autocompletable lists
widget_date.js - fancy date picker for browsers without native HTML5 one
widget_color.js - fancy color picker for browsers without native HTML5 one
0 guests and 0 members have recently viewed this.