JavaScriptCharacterData is a small but significant portion of JavaScript and Ajax based application. This function is used with DOM wherein it provides additional information for DOM for proper interpretation.
CharacterData is used with actual text or connected after the text is written. As a key to DOM’s interaction with the text, CharacterData treats a single line of data as a node. A node would usually look this way:
<p>Sample Test Placed Here</p>
This will be defined by CharacterData by the number of characters and the actual text found inside the node.
The advantage of CharacterData is in its flexibility in terms of functionality. It can be used for large amount of nodes or it could not be used at all. When the application has very limited texts, it is possible that the CharacterData will not provide DOM with any data to manipulate.
Another advantage of CharacterData is the enabling of easy representation of texts to DOM. By transforming texts into a node with additional data, DOM could easily interact with text through additional functions.
The sole function of CharacterData is to define the node to DOM and nothing more. If the developer wants to make additional features in the node, AppendData could be a good option. This could be easily launched after the text has been added wherein it will present an argument or a parameter on how the nodes will further change. Ultimately, the text will be added with string so that functionalities will be added when they are read by DOM.
AppendData could also be used to tie two nodes or separate their functionality when launched in the application. The first node will be solely defined with CharacterData while the other node will have additional features through AppendData.
Even though appendData would seem to offer an efficient function for JavaScript and Ajax, there are other options that could be considered aside from appendData. Apparently, JavaScript already has a string manipulator. Like appendData, it does have the power to make some changes on the nodes.
However, appendData could still be useful in so many ways. For example, a small JavaScript plug-in or API that does nOt need a lot of data but functions that will complement the application. The appendData portion of this type of software will be limited but would provide the much needed data manipulation.
Although CharacterData could provide a clear advantage for developers, executing this function in IE is a little bit challenging. Since IE 5.5, the reaction of the browser to CharacterData commands are never complete. This could be easily noticed when you are trying to run CharacterData in HTML.
The later versions would “fix” this concern but it did something else – the normalize command implemented in nodes is not recognize. Although it will not drag down the application, the nodes will continue to use up resources because when run in IE. The appendData on the other hand should have no problems in running on IE 6 and later but the IE 5.5 cannot recognize the command.