KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Recently I saw some HTML with only a single <script> element in its <head> ... <head> <title>Example</title> <script src="script.js" type="text/javascript"></script> <link href="plain.css" type="text/css" rel="stylesheet" /> </head> This script.js then adds any other necessary <script> elements and <link> elements to the document using document.write(...) : (or it could use document.createElement(...) etc) document.write("<link href=\"javascript-enabled.css\" type=\"text/css\" rel=\"styleshet\" />"); document.write("<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js\" type=\"text/javascript\"></script>"); document.write("<script src=\"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js\" type=\"text/javascript\"></script>"); document.write("<link href=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/trontastic/jquery-ui.css\" type=\"text/css\" rel=\"stylesheet\" />") document.write("<script src=\"validation.js\" type=\"text/css\"></script>") Note that there is a plain.css CSS file in the document <head> and script.js just adds any and all CSS and JavaScript which would be used by a JS-enabled user agent. What are some of the pros and cons of this technique?
Tags (comma-separated)
Save Edits
Cancel