怎样动态地插入不会暴露给用户的JS文件
也是无意间看见的,以前想过这个问题,但是没多想,今天看到这段代码豁然开朗
(function() { var dynamicScript = document.createElement('script'); dynamicScript.type = 'text/javascript'; dynamicScript.async = true; dynamicScript.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.xxx.com/dynamicScript.js'; var firstScript = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(dynamicScript, firstScript); })();