Menu
About me Kontakt

The article 'Why not document.write?' on CSS Wizardry discusses the use of the document.write() method in JavaScript. The author emphasizes that while this technique was popular in the past, it now seems outdated. There are many alternatives that are more efficient and align with modern programming standards. For instance, instead of using 'document.write()', dynamic insertion of elements into the DOM using JavaScript can create more flexible and efficient web applications.

The article also points out that using 'document.write()' comes with certain risks, especially regarding asynchronous page loading. It can lead to rendering issues since this method might overwrite the entire HTML of a page, resulting in the loss of existing content. Furthermore, there are other techniques, such as using 'innerHTML' or 'appendChild()', which allow the addition of new elements without overwriting the whole content.

Another significant point raised by the author is performance. Over the years, browsers have become more sophisticated and can better handle modern DOM techniques. The use of document.write() can cause slowdowns because it requires reinterpreting page content. The author suggests that developers adopt better practices and avoid outdated solutions like document.write() in favor of more contemporary methods.

The article also includes examples illustrating how changes in the approach to DOM manipulation can lead to significantly better outcomes. It emphasizes the need for a conscious approach to coding, considering not only functionality but also future maintenance and the understanding of code by other programmers.

Finally, the author encourages experimentation with new ways of manipulating web content and rethinking how our technological choices impact the future of web applications. In a rapidly evolving technology landscape, it is essential to stay up-to-date with modern practices and strive for better solutions that benefit both developers and end users.