What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 129 Stack Exchange communities.

This is a spin off of this question: Why is the SO system message written in by javascript?

Why would they use document.write?

Current Code on page:

<div id="system-message-temp">

<script type="text/javascript">

    var curSystemMessage = 'SOPA is a dangerous law. It breaks the Internet and threatens sites like Stack Overflow. <a href="http:\/\/americancensorship.org\/" rel="nofollow">Protect the Internet<\/a>!';

    document.write(curSystemMessage); //WHAT? Why....?

    $('#system-message-temp').attr('id', 'system-message');

</script>

</div>

Why didn't they totally drop that and use jQuery?

<div id="system-message-temp">

<script type="text/javascript">

    var curSystemMessage = 'SOPA is a dangerous law. It breaks the Internet and threatens sites like Stack Overflow. <a href="http:\/\/americancensorship.org\/" rel="nofollow">Protect the Internet<\/a>!';

    $('#system-message-temp').html(curSystemMessage).attr('id', 'system-message');

</script>

</div>
share|improve this question
4  
Oh dear, I hope this doesn't start a jQuery flame war... –  Adam Rackis Nov 29 '11 at 18:54
    
@Shad it doesn't :-D –  amanaP lanaC A nalP A naM A Nov 29 '11 at 18:56
1  
Uhm... why not? Also, this sounds more like a Stack Overflow question to me. –  balpha Nov 29 '11 at 19:01
1  
@balpha I am asking about SO. you don't ask about SO on SO :-P –  amanaP lanaC A nalP A naM A Nov 29 '11 at 19:03
2  
Why didn't they totally drop that and use jQuery?...and I who thought that memes where funny exaggerations... meta.stackexchange.com/a/19492/163321 –  Damien Pirsy Nov 29 '11 at 20:44
    
@DamienPirsy hehe who mem-fied my Q? :-P –  amanaP lanaC A nalP A naM A Nov 29 '11 at 20:54
    
@AManAPlanACanalPanama: hehe...me :) –  Zach Johnson Nov 29 '11 at 23:29
    
Yay for palindromic usernames! –  squint Jan 17 '12 at 1:23

1 Answer 1

up vote 14 down vote accepted

Originally the system messages was set via jQuery, but "flashed" unpleasantly. Using document.write avoided this.

Now, the old jQuery code was last tested more than a year ago (a few jQuery versions ago, and many of the then supported browsers are no longer supported) so this may no longer be a valid concern. However, the code works so we've had no reason to revisit it since it was written.

share|improve this answer
1  
+1 seems like a valid answer, I can't verify but I remember we had something similiar due to jQuery flashing. If it ain't broke don't fix it...or something like that :-). –  JonH Nov 29 '11 at 19:09
3  
This is still an issue, as people complaining about the flashing of questions with ignored tags will confirm :-) –  balpha Nov 29 '11 at 19:12
    
(and yes, I know that's nowadays happening in a lazy-loaded JS file, but with the file being in the cache, that doesn't matter) –  balpha Nov 29 '11 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .