Solved

CDATA

Posted on 2012-03-10
5
406 Views
Last Modified: 2012-03-16
Can someone kindly explain what this code block is doing?  Inherited code and I am not familiar with CData.

  <script type='text/javascript'>
    //<![CDATA[
      !window.jQuery && document.write(unescape('%3Cscript src="../js/libs/jquery-1.7.1.min.js"%3E%3C/script%3E'));    // scripts concatenated and minified via ant build script
    //]]>
  </script>

Open in new window

0
Comment
Question by:kkbenj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
StingRaY earned 250 total points
ID: 37704908
This script includes jQuery framework if it is not included.
CDATA block is a character data block, usually used in XHTML.
If you are writing a plain HTML, you can remove "//<![CDATA[" and "//]]>".
0
 
LVL 35

Assisted Solution

by:Robert Schutt
Robert Schutt earned 250 total points
ID: 37704910
The CDATA part is commented out but could be necessary to maintain valid xml/xsl at some other point.

The javascript code checks if jQuery is available and if not, insert the script tag to include it into the html.
0
 

Author Comment

by:kkbenj
ID: 37704916
Nothing in XHtml.  Thank you for the information.

One more related question: is that block of code even necessary since:
      <script src='../js/libs/jquery-1.7.1.min.js'></script>
is included in the header?
0
 
LVL 15

Expert Comment

by:StingRaY
ID: 37704917
No, it is not necessary anymore.
0
 

Author Closing Comment

by:kkbenj
ID: 37704920
Thank you both!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question