Home  >  Article  >  Web Front-end  >  Two ways to dynamically load script files_javascript tips

Two ways to dynamically load script files_javascript tips

WBOY
WBOYOriginal
2016-05-16 17:25:281240browse

There are about two ways to dynamically load scripts to the page

The first is to use ajax to load the script file code from the background to the foreground, and then execute the code through eval() on the loaded content. The second is to dynamically create a script tag, set its src attribute, and load js by inserting the script tag into the head of the page, which is equivalent to writing a