javascript - Is it possible to force a certain js file to be loaded first?
PHP中文网
PHP中文网 2017-06-13 09:21:49
0
4
813

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

PHP中文网
PHP中文网

认证0级讲师

reply all(4)
学霸

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

我想大声告诉你

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

迷茫

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.

曾经蜡笔没有小新

script tag is placed first

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template