xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

js script all in one

你不知道的 js secret

https://html.spec.whatwg.org/multipage/scripting.html

https://html.spec.whatwg.org/multipage/scripting.html#attr-script-async

https://html.spec.whatwg.org/multipage/scripting.html#attr-script-defer

defer vs async

https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script



module

.mjs

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules

<script type="module">
  import {addTextToBody} from './utils.mjs';

  addTextToBody('Modules are pretty cool.');
</script>

// utils.mjs
export function addTextToBody(text) {
  const div = document.createElement('div');
  div.textContent = text;
  document.body.appendChild(div);
}

    <script src="./libs/json5.min.js"></script>
    <script type="module">
        // const JSON5 = require('json5'); 
        import * as JSON5 from "./libs/json5.min.js";
        // JSON5.stringify(value[, replacer[, space]]);
        // JSON5.stringify(value[, options]);
    </script>

https://github.com/json5/json5/issues/187

type


refs

https://dev-preview.cnblogs.com/xgqfrms/p/12371162.html

async, defer and preload

https://hacks.mozilla.org/2017/09/building-the-dom-faster-speculative-parsing-async-defer-and-preload/

prefetch & preload & prerender

https://www.cnblogs.com/xgqfrms/p/8984852.html

dns-prefetch

https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


原文地址:https://www.cnblogs.com/xgqfrms/p/13676590.html