HTML: adding <STYLE> and <SCRIPT> tags via JavaScript

If the JavaScript function on the web page adds elements to STYLEeither SCRIPTthe element HEAD, does the browser load the specified styles and scripts, or are such program changes in the DOM ignored after the page is loaded?

Is the behavior state in all major browsers?

+5
source share
1 answer

Yes, you can add scripts and style sheets through JavaScript, and they will work. For example, Google Analytics does this.

+7
source

All Articles