jquery loading of feedback widget overwrites page.

  • Problem
  • Updated 2 years ago
  • In Progress
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members. The community moderator provided the following reason for archiving: Community cleanup. Issue is out of date and has not had any recent activity. If this issue still persists please start a new topic! :)

jQuery $.getScript() usage with feedback widget rewrites entire page with feedback widget.

This is to avoid the document.write() call because that causes speculative parsing failures in Firefox 11.

This is exceedingly easy to reproduce. Either loading on dom content ready, page load event, or executing it immediately will overwrite the entire document.

$.getScript(location.protocol + "//s3.amazonaws.com/getsatisfaction.com/javascripts/feedback-v2.js", function() {
new GSFN.feedback_widget({
display: 'overlay',
company: 'yourcompany',
placement: 'left',
color: '#222',
style: 'question'
});

I have serious reservations with using the should-be-deprecated document.write() function. Triggering speculative parsing failures in Firefox is unacceptable behavior for 3rd party libraries.

Steven Berlan

  • 3 Posts
  • 0 Likes
  • sad

Posted 2 years ago

  • 2

Jenn Lin, GetSat Alumni

  • 529 Posts
  • 19 Likes
Hi Steven!

It sounds like you know a lot more than I do on this topic, but I want to make sure we are on as close to the same page as possible so I can help work on a solution.

Can you share either the full code for the page or a hosted page location that I could look at?

Thanks!
Jenn

Steven Berlan

  • 3 Posts
  • 0 Likes
Just looked through feedback-v2.js.

Going to fix this by assigning container in the options, but you should never use document.write() in production code, nor should you ever overwrite the contents of a container: append to containers.

Listen to DOMContentLoaded, listen to window load event, I don't care. Default container to document.body, override it with this.options.container if its set.

Do not use the document.write() function, it has performance penalties. This was not acceptable in 2004, it is not acceptable now.

Jenn Lin, GetSat Alumni

  • 529 Posts
  • 19 Likes
Hello Steven,

Thank you for the feedback. I have filed a bug with the team to address it. We are investigating several major changes to the widget code, and this feedback will be taken into account in that work.

I am glad you found a workaround in the container option. And thank you again for taking a look!

Jenn

Steven Berlan

  • 3 Posts
  • 0 Likes
https://gist.github.com/2347239

Well, if they care, I refactored the code of feedback-v2.js to be a lot cleaner than what it currently is. I haven't changed everything, or even tested all of it, but it appears to work the same in Firefox as before. Do what you want with the gist.

Anyway, it's a good jumping point from there, and smaller in size to boot.

Jenn Lin, GetSat Alumni

  • 529 Posts
  • 19 Likes
Thank you! I will pass this along as well.

This conversation is no longer open for comments or replies.