Home > Web Front-end > HTML Tutorial > HTML dynamic loading css style and js script example_HTML/Xhtml_web page production

HTML dynamic loading css style and js script example_HTML/Xhtml_web page production

WBOY
Release: 2016-05-16 16:38:14
Original
1356 people have browsed it

1. Dynamic loading script

As the demand for the website increases, the demand for scripts also gradually increases. We had to introduce too many JS scripts and reduced the performance of the entire site, so the concept of dynamic scripts emerged to load the corresponding scripts at the right time.
For example: We want to introduce the detection file when we need to detect the browser.


Copy code
The code is as follows:

Dynamic execution of js


IE 6, 7, and 8 browsers consider script to be a special element and cannot access child nodes. For compatibility, the text attribute can be used instead.


Required for all browsers Compatible

2. Dynamically loading styles

In order to dynamically load style sheets, such as switching website skins. There are two ways to load style sheets, one is the tag, and the other is the