search

Home  >  Q&A  >  body text

javascript - Is it possible to force a certain js file to be loaded first?

In addition to sequential loading, is there any other way to load a certain js file first?

PHP中文网PHP中文网2763 days ago850

reply all(4)I'll reply

  • 欧阳克

    欧阳克2017-06-13 09:23:49

    You can consider using preload/prefetch, the usage method is as follows:

    <link rel="preload" href="xx.js" as="script">

    Related information:
    Preload: What Is It Good For?
    What should you know about Preload? Chinese translation of the above article

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-06-13 09:23:49

    The simplest way is to write the priority js file in the page and load other js files in onload.

    reply
    0
  • 迷茫

    迷茫2017-06-13 09:23:49

    Little Red Book, Chapter 2, 2.1 "script" element async: Optional, indicating that the script should be downloaded immediately, but does not hinder other operations on the page. Give it a try.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-13 09:23:49

    script tag is placed first

    reply
    0
  • Cancelreply