Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1005253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:15:53+00:00 2026-05-16T08:15:53+00:00

From the Flattr Javascript API description : <script type=text/javascript> <!–//–><![CDATA[//><!– (function() { var s

  • 0

From the Flattr Javascript API description:

<script type="text/javascript">
<!--//--><![CDATA[//><!--

    (function() {
        var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];

        s.type = 'text/javascript';
        s.async = true;
        s.src = 'http://api.flattr.com/js/0.5.0/load.js';

        t.parentNode.insertBefore(s, t);
    })();

//--><!]]>
</script>

I am a bit curious about the <!--//--><![CDATA[//><!-- and //--><!]]>. I guess that are some hacks to trick old browsers who don’t understand the <script>-tag. But isn’t the <!-- enough? What exactly is the CDATA stuff about? And if I don’t care about old browsers, all this is obsolete anyway, right? (Btw., does someone know any browser at all who would get confused if I would not put this stuff there?)

Then I wonder about the function definition. Why is it there? Why not call the code directly? Is it to not spam the global namespace? If so, aren’t there easier, less hacky ways to do this, e.g. just putting the code into {}?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:15:54+00:00Added an answer on May 16, 2026 at 8:15 am

    It is a combination of hacks that, between them:

    • Cope with browsers from before HTML introduced the script element (over a decade ago)
    • Cope with JavaScript that includes &, < and > in XHTML
    • Compensate for the XHTML solution when the XHTML is treated as HTML instead of XHTML (i.e. almost always)
    • Stops the other hacks from interfering with each other

    Frankly, you can (and should) forget about browsers which don’t understand <script> (note, this is not the same as not supporting JS, it means not recognizing the element at all so treating it (effectively) as a <span>). If you do that and use XHTML then you can just use CDATA flags prefixed with JS comments ( // ).

    You should generally also avoid XHTML. Unless you are dealing with a server side system that insists of generating XHTML and it is more effort to convert it to HTML then it is to deal with all the issues of writing HTML-Compatible XHTML, then XHTML is almost never worth the cost.

    If you aren’t using XHTML or caring about browsers which don’t even speak HTTP 1.1, then you just need the script tags and the script, without any wrappers at all.

    In this particular example, you don’t need the CDATA flags anyway – the script doesn’t include any characters that have special meaning in XML, so you don’t need an instruction to treat those characters as text instead of markup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the Scala API , I got the following example, which does not compile;
from fabric.api import sudo, put, run def install(): run('source /home/user/.virtualenvs/demo/bin/activate') run('pip install requests') if
From http://www.parashift.com/c++-faq-lite/basics-of-inheritance.html#faq-19.5 A member (either data member or member function) declared in a protected
from fabric.api import env, sudo def get_hostname(): env.hosts = ['user@host_ip'] env.passwords = {'user@host_ip': 'password'}
from urllib import urlopen import re p = re.compile('<h2><a .*?><a .*? href=(.*?)>(.*?)</a>') text =
from Tkinter import * window = Tk() frame=Frame(window) frame.pack() text_area = Text(frame) text_area.pack() text1
From this question:- https://stackoverflow.com/questions/1342611/is-there-a-webservice-api-to-grab-a-screenshot-of-another-website and some other questions/google I got some results like:-- http://www.bitpixels.com/
(from the mailing list) How do I create some sort of text input box
From my website, I have a button which calls a method and then generates
From this context: import itertools lines = itertools.cycle(open('filename')) I'm wondering how I can implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.