1、script中生成
<script type="text/javascript"> (function(){ var randomh=Math.random(); var e = document.getElementsByTagName("script")[0]; var d = document.createElement("script"); d.src = "//site.com/js.js?x="+randomh+""; d.type = "text/javascript"; d.async = true; d.defer = true; e.parentNode.insertBefore(d,e); })(); </script>
2、通过document.write方式实现
<script>document.write("<script type='text/javascript' src='//site.com /js.js?v=" + Date.now() + "'></script>");</script>